Invalid expression term ')' is shown in kendoUI for ASPX ASP MVC4 - asp.net-mvc-3

Invalid expression term ')' is shown in kendoUI for ASPX ASP MVC4
code:
<%: Html.Kendo().Grid(gridobj)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.TMovie_id).Groupable(false).Title("ID");
columns.Bound(p => p.Name).Title("Name");
columns.Bound(p => p.Genre).Title("Genre");
columns.Command(command => command.Custom("Edit").Click("Editfunction"));
columns.Command(command => command.Custom("Delete").Click("Deletefunction"));
columns.Template(c => { %> <%= Html.ActionLink("Edit", "EditMovie","Movies") %> <% });
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("", ""))
)
%>
Compilation Error:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1525: Invalid expression term ')'
Source Error:
Line 118: columns.Command(command => command.Custom("Edit").Click("Editfunction"));
Line 119: columns.Command(command => command.Custom("Delete").Click("Deletefunction"));
Line 120: columns.Template(c => { %> <%= Html.ActionLink("Edit", "EditMovie","Movies") %> <% });
Line 121:
Line 122: })

I had the same error.
If you remove ":" from <%: Html.Kendo().Grid , your problem will be solved.

i guess you have an additional ) in your code
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("", ""))
-----------------------------------------^
)
on a side note i think there is no need to close the %> before using the helper this should work
<%: Html.Kendo().Grid(gridobj)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.TMovie_id).Groupable(false).Title("ID");
columns.Bound(p => p.Name).Title("Name");
columns.Bound(p => p.Genre).Title("Genre");
columns.Command(command => command.Custom("Edit").Click("Editfunction"));
columns.Command(command => command.Custom("Delete").Click("Deletefunction"));
columns.Template(c => { Html.ActionLink("Edit", "EditMovie","Movies") });
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("", "")
)
%>

Related

Kendo UI Grid MVC - Why does an Edit button appear at the end of each row when in-cell mode is set?

I have code that looks as follows:
#(Html.Kendo().Grid<JeffreysOnline.Entities.Customer>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.LastName).Width(150);
columns.Bound(p => p.FirstName).Width(125);
columns.Bound(p => p.MiddleInitial).Width(75);
columns.Bound(p => p.Phone).Width(125);
columns.Bound(p => p.Address).Width(150);
columns.Bound(p => p.City).Width(100);
columns.Bound(p => p.State).Width(50);
columns.Bound(p => p.Zip).Width(125);
columns.Bound(p => p.TaxName).Width(125);
columns.Bound(p => p.TaxId).Width(125);
columns.Bound(p => p.BadChecks).Width(125);
columns.Bound(p => p.OtherRisk).Width(125);
columns.Bound(p => p.Interests).Width(125);
columns.Bound(p => p.BirthDate).Width(125);
columns.Bound(p => p.BouncedCheck).Width(125);
columns.Bound(p => p.PCNumber).Width(125);
columns.Bound(p => p.Comments).Width(125);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
toolbar.Excel();
})
.Editable(editable => editable.Mode(GridEditMode.InCell)) // In-cell editing instead of the whole row
.Pageable()
.Navigatable() // This allows the user to tab between columns in the grid.
.Sortable()
.Scrollable()
.Groupable()
.Excel(excel => excel
.FileName("Customers.xlsx")
.Filterable(true)
.AllPages(false)
.ProxyURL(Url.Action("ExcelExport", "Customer"))
)
.HtmlAttributes(new { style = "height:700px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true) // We want to perform batch operations
.PageSize(500) // Set the page size
.Events(events => events.Error("error_handler")) // Define a function that gets called on an error
.Model(model => model.Id(p => p.RowId)) // Define the PK
.Create(update => update.Action("Create", "Customer")) // The Create method in the controller
.Read(read => read.Action("Read", "Customer")) // The Read method in the controller
.Update(update => update.Action("Update", "Customer")) // The Update method in the controller
.Destroy(update => update.Action("Delete", "Customer")) // The Delete method in the controller
)
When the grid renders on the page, an Edit button appears in the last column:
Why is this edit button appearing when I have in-cell editing mode set?
Do you mean the Edit button? You're adding it in your code here:
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
Remove the command.Edit(); statement and the button should disappear.

Kendo Grid MVC - DataSource Error

I'm just starting to learn Kendo UI MVC and am running across the following issue. Here is my code:
#(Html.Kendo().Grid<JeffreysOnline.Entities.Customer>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.FirstName);
columns.Bound(p => p.LastName);
columns.Bound(p => p.Address);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ProductID))
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
)
I'm getting the following error, with line 23 highlighted.
Compiler Error Message: CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type
Line 21: .Scrollable()
Line 22: .HtmlAttributes(new { style = "height:550px;" })
Line 23: .DataSource(dataSource => dataSource
Line 24: .Ajax()
Line 25: .PageSize(20)
It appears it doesn't like 'dataSource' but I have no clue what it would be expecting.
If ProductId is not a property of your model, this may be causing the error.
It appears you took the example almost directly from telerik's inline editing tutorial page at: http://demos.telerik.com/aspnet-mvc/grid/editing-inline, so try adjusting the column this is pointing to for your Model within the data source. like so:
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.RandyMindersActualIdColumnProperty)) // Here is the change
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)

Problems with Filtering Rows using the Kendo UI Grid control

I am using this example from Telerik site which demos how to add a filter to your grid. I am following the example exactly how it is shown which is below:
#(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(225);
columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.Freight).Width(255).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(true)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)
However, when I use I run my site, I get an error on line
columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
saying that "Cannot convert lambda expression to type 'bool' because it is not a delegate type."
I dont know what I am doing wrong as my code is exactly the same as the demo code.
Any help is appreciated!
Wixstar
columns.Bound(p => p.ShipName).Width(500).Filterable(ftb=> ftb.Extra(false));
This will work for you,no need to use Operator("...")
if this will help you than mark this answer as correct answer.

Kendo UI Custom Pop-up Editor in Hierarchical Grid

I have a Hierarchical grid and I'm trying to add a custom editor for pop-up editing. When I add the template to the child grid and click on the "edit" button, i get a invalid template error. If i add that same template to the parent, it works fine.
Here is the error in console:
Uncaught Error: Invalid template:'
Here is the code
#(Html.Kendo().Grid<ParentViewModel>()
.Name("GridAdjax")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Read", "controller"))
.Model(model =>
{
model.Id(c => c.Id);
})
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Columns(columns =>
{
columns.Bound(p => p.CompanyName).Title("Company Name");
columns.Bound(p => p.CompanyDomain).Title("Company Domain");
columns.Bound(p => p.CompanySecurityRole).Title("Security Role");
columns.Bound(p => p.CompanySecurityGroup).Title("Security Group");
})
.ClientDetailTemplateId("template")
.Pageable()
.Sortable()
.Resizable(resize => resize.Columns(true))
.Events(e => e.DataBound("OnDataBound"))
.Deferred()
)
<CHILD>
<script id="template" type="text/kendo-tmpl">
#(Html.Kendo().Grid<ChildlViewModel>()
.Name("grid_#=CompanyId#")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Update(update => update.Action("CompanyList_Update", "Administration"))
.Read(read => read.Action("Read", "Child", new { companyId = "#=CompanyId#" }))
.Model(model =>
{
model.Id(c => c.Id);
model.Field(c => c.CompanySoldTo).Editable(true);
model.Field(c => c.CompanyDistributionChannel).Editable(true);
model.Field(c => c.CompanyDivision).Editable(true);
model.Field(c => c.CompanyPlant).Editable(true);
model.Field(c => c.CompanySalesOrg).Editable(true);
})
)
.Columns(columns =>
{
columns.Bound(p => p.CompanySoldTo).Title("Sold To");
columns.Bound(p => p.CompanyDistributionChannel).Title("Dist. Chan.");
columns.Bound(p => p.CompanyPlant).Title("Plant");
columns.Bound(p => p.CompanySalesOrg).Title("Sales Org");
columns.Command(command => { command.Edit(); }).Title(("Edit SAP Info."));
})
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Detail"))
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
</script>
If anyone experiences this issue in the future, the problem was actually in my custom pop-up editor template. I had a data validation message on one of the input boxes set as "Please enter your account #". The "#" was being interpreted as a template by Kendo. I escaped the # and then was able to get it to successfully load.

The best overloaded method match for Kendo.Mvc.UI.Fluent.GridEditingSettingsBuilder

The best overloaded method match for Kendo.Mvc.UI.Fluent.GridEditingSettingsBuilder Mode(Kendo.Mvc.UI.GridEditMode) has some invalid arguments .Filterable() and .Scrollable()
This is the error I get while I run the project which has the KendoUI Grid Control.
The code is similar to what is there in the KendoUI website , however on my project I do get this error. I am able to get the Filterable() option in the intellisense but am not sure why the error is thrown . I can see the error in Firebug and it is not thrown by the webpage as a yellow screen of death.
Any help would be appreciated.
My sample code is as below
CS HTML Code
#using Kendo.Mvc.UI;
#model IEnumerable<MvcApplication29.Models.CustomItem>
<div class="absolute-position">
<div class="absolute-position">
#(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(o => o.No).Width("15%");
columns.Bound(o => o.ShortDesc).Width("15%");
columns.Bound(o => o.Category).Width("6%");
})
.Sortable()
.Pageable(p=>p.Refresh(true))
.Filterable()
.Scrollable()
.Editable(edit => edit.DisplayDeleteConfirmation("Are You Sure To Delete This ").Mode(GridEditMode.PopUp))
.ColumnMenu(col=>col.Sortable(false))
.Groupable()
.ToolBar(toolbar => toolbar.Create())
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
//.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("GetItemsHome", "det"))
.Model(model => {
model.Id(p => p.ID);
})
.Create(update => update.Action("EditingInline_Create", "det"))
// .Read(read => read.Action("EditingInline_Read", "Default1"))
.Update(update => update.Action("EditingInline_Update", "det"))
.Destroy(update => update.Action("EditingInline_Destroy", "det"))
)
)
</div>
</div>
///CS Code
public ActionResult GetItemsHome1([DataSourceRequest] DataSourceRequest request , int page)
{
List<CustomItem> lst = new List<CustomItem>();
return Json(lst.ToDataSourceResult(request));
}

Resources