Kendo grid delete command not firing (MVC) - asp.net-mvc-3

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

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.

kendo grid do not refresh on update

I have the next Kendo Grid, all the events in the models take place, no problem!.
The problem is when I change a value in the grid, it not refresh again.
How I can fix this, or how I can get the event occurring when I do changes on the grid, to manage the grid refresh with JQuery.
#(Html.Kendo().Grid<Corporativo.Model.SolProdVM>()
.Name("SolicitudesProducto")
.Columns(columns =>
{
columns.Bound(e => e.Id_Producto).Width(80).Title("Código");
columns.Bound(e => e.DescProducto).Width(40).Groupable(false).Title("Producto");
columns.Bound(e => e.UM).Width(40).Groupable(false).Title("UM");
columns.Bound(e => e.Precio).Width(40).Groupable(false).Title("Precio");
columns.Bound(e => e.Cantidad).Width(40).Groupable(false).Title("Cantidad");
columns.Bound(e => e.Importe).Width(40).Groupable(false).Title("Importe");
columns.Command(command => command.Custom("Eliminar").Click("elimar_de_solicitud")).Width(25);
})
.Sortable()
.ToolBar(toolBar =>
{
toolBar.Save().Text("Guardar cambios");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Filterable()
.Pageable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => {
model.Id(p => p.Id_Solicitud);
model.Id(p => p.Id_Producto);
model.Field(p => p.Desc_Producto).Editable(false);
model.Field(p => p.UM).Editable(false);
model.Field(p => p.Precio).Editable(false);
model.Field(p => p.Cantidad);
model.Field(p => p.Importe).Editable(false);
})
.Read(read => read.Action("GetAllSolProdJSON", "ProductRequest", new { Id_Solicitud = #Model.Id_Solicitud }))
.Update(update => update.Action("ActualizarSolProd", "ProductRequest").Type(HttpVerbs.Post))
.Destroy(destroy => destroy.Action("EliminarSolProd", "ProductRequest").Type(HttpVerbs.Post))
)
)
There is an Events Method you can call.
#(Html.Kendo().Grid<Model_MVC.Models.OrderGridViewModel>()
.Name("ProposalGrid")
.HtmlAttributes(new { style = "font-size:14px;line-height:2em;width:80%;margin-left:190px;" })
.Columns(columns =>
{
//columns
})
.
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Orders_Read", "Orders"))
.Events(x => x.Change("JSFunction") )
.Model(model =>
{
model.Id(i => i.OrderId);
model.Field(x => x.OrderId).Editable(false);
})
.PageSize(15)
)
.Pageable()
)

Kendo grid dynamic model field binding issue with kendo version 2013.3.1119

I have use Kendo version 2012.03.1114 and below mention code to add value to model and work fine but when I update the kendo varsion to 2013.3.1119 it will give a error
(TypeError: $(...).data(...).kendoGrid.editable is undefined)
any workaround please?
var model = $('#grid').data().kendoGrid.editable.options.model;
model.set('Name', getNames());
#(Html.Kendo().Grid<ABC.Domain.Entities.user>()
.Name("Grid")
.Columns(columns => {
columns.Command(command => { command.Edit(); }).Width(80);
columns.Bound(u => u.Name).Title("Name").Width(150);
columns.Bound(u => u.Status).Title("Status").Width(70);
columns.Bound(u => u.Address).Title("Address").Width(100); })
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("userEdit")) .Events(events => events.DataBound("onDataBound").Edit("onEdit"))
.Pageable(paging => paging.PageSizes(new int[] { 5, 10, 20, 50 })
.Refresh(true))
.Sortable() .ToolBar(toolbar => toolbar.Create())
.Resizable(resize => resize.Columns(true))
.Scrollable()
.DataSource(dataSource => dataSource .Ajax() .Model(model => { model.Id(p => p.userKey); }) .PageSize(5) .Events(events => events.Error("error_handler"))
.Read(read => read.Action("user_Read", "User"))
.Update(update => update.Action("User_Update", "User"))
.Create(create => create.Action("User_Create", "User")) ) )

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