The best overloaded method match for Kendo.Mvc.UI.Fluent.GridEditingSettingsBuilder - asp.net-mvc-3

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));
}

Related

cannot convert lambda expression to type ienumerable because it is not a delegate type in kendo grid mvc

I am trying to bind dropdown in kendo grid MVC but it's giving me the error
cannot convert lambda expression to type ienumerable because it is not
a delegate type
Below is my code
#(Html.Kendo().Grid<mymodel.TableRelationShip>()
.Name("myid").HtmlAttributes(new { #class = "table-responsive grid-table" })
.Columns(columns =>
{
columns.ForeignKey(p => p.PK_User_Table, ds=>ds.Read(r => r.Action("User_Table", "PageManagement")), "PK_User_Table", "TableName")
.Title("Primary Table").Width(200);
columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
.Pageable()
.Navigatable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.PKID);
model.Field(p => p.PKID).Editable(false);
model.Field(p => p.PK_User_Table).DefaultValue(1);
})
.Create(Create => Create.Action("xyz", "mycontroller").Data("additionalInfo"))
.Read("xyz", "mycontroller")
.Update("xyz", "mycontroller")
.Destroy("xyz", "mycontroller")
)
)

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.

MVVM pattern in Kendo Grid

I'm using the Kendo Grid control to display some data and it's working OK. This is the code:
#(Html.Kendo().Grid<MyModel>()
.Name("MyGrid")
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add New Line").HtmlAttributes(new { #Class = "btn btn-primary" });
})
.Columns(columns =>
{
columns.Bound(p => p.Description).HtmlAttributes(new {style = "font-size: 9pt;"});
columns.Bound(p => p.Value);
columns.Command(cmd =>
{
cmd.Edit();
cmd.Destroy();
}).Width(200);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Selectable(s => s.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
.DataSource(data => data
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.ServerOperation(false)
.Read(read => read.Action("ReadAction", "MyController"))
.Create(create => create.Action("CreateAction", "MyController"))
.Update(update => update.Action("UpdateAction", "MyController"))
.Destroy(delete => delete.Action("DeleteAction", "MyController"))
))
The code above is working without any problem. Now, what I'm trying to implement is to display the same data using the MVVM pattern. I mean, I would like to have the same operations (create, update, delete) in my viewmodel without calling the server actions of my controller as the code above does.
I have google it for a while but without any luck.
Any help would be very appreciate

kendo mvc grid hierarchy dropdownlist create fails

This is my code:
#(Html.Kendo().Grid<RMS.Admin.ViewModel>()
.Name("ResourceGrid")
.Columns(columns =>
{
columns.Bound(c => c.ResourceName);
columns.Bound(c => c.Descritption);
columns.Bound(c => c.ResourceType).ClientTemplate("#=ResourceType.Name#");
columns.Bound(c => c.Approved);
columns.Bound(c => c.IsEnabled);
columns.Bound(c => c.Data).Width(220);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(172).Title("Edit/Delete");
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Scrollable()
.Sortable()
.HtmlAttributes(new { style = "height:800px" })
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(s => s.ResourceId);
model.Field(p => p.ResourceType).DefaultValue(ViewData["defResourceType"] as RMS.Admin.ViewModel.ResourceTypeId);
})
.Create(update => update.Action("CreateResource", "Home", new { resourceTypeId = "#=ResourceType.Id#" }))
.Read(read => read.Action("ReadResource", "Home"))
.Update(update => update.Action("SaveSystem", "Home"))
.Destroy(destroy => destroy.Action("RemoveSystem", "Home"))
)
.Events(events => events.DataBound("dataBound"))
)
<script id="template" type="text/kendo-tmpl">
#(Html.Kendo().Grid<RMS.Admin.Metadata>()
.Name("grid_#=ResourceId#")
.Columns(columns =>
{
columns.Bound(o => o.MetaDataName);
columns.Bound(o => o.MetaDataDescription);
columns.Bound(o => o.LanguageCode);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(172).Title("Edit/Delete");
})
.HtmlAttributes(new { style = "height:500px" })
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Model(model => model.Id(s => s.MetaDataId))
.Read(read => read.Action("GetMetaDataByResourceId", "Home", new { id = "#=ResourceId#" }))
.Create(update => update.Action("CreateMetaData", "Home", new { id = "#=ResourceId#" }))
.Update(update => update.Action("SaveSystem", "Home"))
.Destroy(destroy => destroy.Action("RemoveSystem", "Home"))
)
.Scrollable()
.Sortable()
.ToClientTemplate()
)
So when i add clienttemplate to resourcetype on the main grid everything works as it should but when i press create button is tells me
"Uncaught ReferenceError: ResourceType is not defined "
If i take clienttemplate away the dropdownlist in the grid wont work.

Kendo grid delete command not firing (MVC)

I setup a Kendo grid with an delete command.
Only the delete action is never fired when pushed on the delete button.
Here is my code:
view:
#(Html.Kendo().Grid<portal.Models.UserVisitor>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(v => v.visitorName).Filterable(false).Title("Visitors");
columns.Command(command => command.Destroy());
})
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Batch(true)
.Model(model =>
{
model.Id(v => v.fkVisitorId);
model.Field(v => v.visitorName).Editable(false);
})
.PageSize(20)
.Read(read => read.Action("Visitors_Read", "Visitor"))
.Destroy(update => update.Action("Visitors_Delete", "Visitor"))
)
.Resizable(resize => resize.Columns(true))
)
Controller Visitor:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Visitors_Delete([DataSourceRequest] DataSourceRequest request,UserVisitor model)
{
return Json(ModelState.ToDataSourceResult());
}
Does anyone know what is wrong with this??
You need to use InLine editing mode if you want the Destroy command to immediately hit the server:
#(Html.Kendo().Grid<portal.Models.UserVisitor>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(v => v.visitorName).Filterable(false).Title("Visitors");
columns.Command(command => command.Destroy());
})
.Sortable()
.Scrollable()
.Filterable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Batch(true)
.Model(model =>
{
model.Id(v => v.fkVisitorId);
model.Field(v => v.visitorName).Editable(false);
})
.PageSize(20)
.Read(read => read.Action("Visitors_Read", "Visitor"))
.Destroy(update => update.Action("Visitors_Delete", "Visitor"))
)
.Resizable(resize => resize.Columns(true))
)
Try explicitly defining the action the grid should take.
.Destroy(update => update.Action("Visitors_Delete", "Visitor")).Type(HttpVerbs.Post))

Resources