i do not understand why the row is not deleted from the database.Actually is not getting on the server,to execute the delete action from the controller only on the client the row is removed .
i get an example from you guys,and i did the same
@(Html.Kendo().Grid<UCMSPayroll.ViewModels.TallyMeasurementViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Template(x => { }).ClientTemplate(
<a class='k-button' href='javascript: void(0)' onclick='deleteRow(this)' style='min-width:32px!important'><span class='k-icon k-delete'></span></a>"
).Width(100);
columns.Bound(p => p.Code).Title(Resources.Resources.FieldText_TM_Code);
columns.Bound(p => p.Name).Title(Resources.Resources.FieldText_TM_Name);
columns.Bound(p => p.MaxLength).Title(Resources.Resources.FieldText_TM_MaxLength).Width(130);
columns.Bound(p => p.IsActive).ClientTemplate("<input type='checkbox' disabled='true' name='IsActive' #= IsActive ? checked='checked' : '' # />").Title(Resources.Resources.FieldText_TM_IsActive);
columns.Bound(p => p.IsHour).ClientTemplate("<input type='checkbox' disabled='true' name='IsHour' #= IsHour ? checked='checked' : '' # />").Title(Resources.Resources.FieldText_TM_IsHour);
columns.Bound(p => p.Precision).Title(Resources.Resources.FieldText_TM_Precision);
columns.Bound(p => p.Priority).Title(Resources.Resources.FieldText_TM_Priority);
columns.Bound(p => p.Formula).Title(Resources.Resources.FieldText_TM_Formula);
})
.ToolBar(toolBar => toolBar.Template(@"<a class='k-button k-button-icontext k-grid-add' onclick='createRow()' href='javascript: void(0)'><span class='k-icon k-add'></span>adauga</a>
<span id='spanAdd' style='display:none'>Add</span>
<div style='float:right;width:150px;color:black;margin-top:5px'><b>Units</b></div>
"
))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.PkTallyMeasurement))
.Create(update => update.Action("EditingInline_Create", "Home"))
.Read(read => read.Action("EditingInline_Read", "Home"))
.Update(update => update.Action("EditingInline_Update", "Home"))
.Destroy(update => update.Action("EditingInline_Destroy", "Home"))
.PageSize(6)
)
)
function deleteRow(element) {
grid = $("#Grid").data("kendoGrid");
grid.removeRow($(element).closest("tr"));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingInline_Destroy([DataSourceRequest] DataSourceRequest request, TallyMeasurementViewModel measurement)
{
if (measurement != null)
{
_tallyMeasurementRepository.Delete(AutoMapper.Mapper.Map<TallyMeasurementViewModel, TallyMeasurement>(measurement));
}
return Json(ModelState.ToDataSourceResult());
}
16 Answers, 1 is accepted
From the provided information it seems that the current behavior is expected with the current grid configuration - the default edit mode is "InCell" in which you should press the "Save Changes" button in the grid toolbar to sync the changes with the server. In current setup however the "Save Changes" button is missing - you can add it using the following HTML:
<
a
class
=
"k-button k-button-icontext k-grid-save-changes"
href
=
"javascript:void(0)"
>
<
span
class
=
"k-icon k-update"
></
span
>Save changes
</
a
>
<
a
class
=
"k-button k-button-icontext k-grid-cancel-changes"
href
=
"javascript:void(0)"
>
<
span
class
=
"k-icon k-cancel"
></
span
>Cancel changes
</
a
>
Kind Regards,
Vladimir Iliev
the Telerik team

If i do not use any editing mode,but i still put actions on datasource(.Destroy,.Update,.Create,.Read) with the crud operations,it will go to the server and execute the actions or do i have to be in one of the 3 editing modes?
Regards,
Daniel
Basically if current grid configuration requires the grid to be editable it automatically sets the edit mode to "InCell" mode. If you need another edit mode you should define it explicitly.
Vladimir Iliev
the Telerik team

for example at this post,
http://www.kendoui.com/forums/mvc/grid/customize-add-delete-edit-buttons.aspx
your colegue sent me an example with custom buttons,there should be also be able to delete from database with the custom image buttons.in that case you delete from database?
Regards,
Daniel
In the example that you pointed the delete button calls the destroy action directly to delete the record on the server ("InLine" / "PopUp" edit modes). The "InCell" edit mode allows the user to batch edit the grid records and sync the changes with the server once the "Save Changes" command is clicked.
Vladimir Iliev
the Telerik team

Regards,
Daniel
The Grid attaches click event handler to all elements with CSS classes "k-grid-save-changes" and "k-grid-cancel-changes" which calls the cancelChanges and saveChanges methods. In current scenario when edit mode in not defined and the grid data is edited the grid will use the default edit mode ("InCell").
Vladimir Iliev
the Telerik team

until now,i managed to do manually the operations,because i do not want to make a batch edit,nor to put a save/cancel button on top.the grid only show read-only data,and when i press delete custom button,to make the action on the server after of course a confirmation.for the edit,i show an edit form with the data from the clicked row,and only then if i press a save button,to make the update with the modified row.
Thank you for the last clarification - for convenience I created small demo of grid without edit mode set (and delete button which sends the deleted record immediately to the server) and attached it to the current thread. Could you please check it and let me know how it differs from your real setup?
Vladimir Iliev
the Telerik team

Regards,
Daniel
Please find attached the updated project.
Vladimir Iliev
the Telerik team

But i keep see in that template
columns.Template(t => { }).HeaderTemplate("").ClientTemplate(@"
<a href='javascript: void(0)' class='abutton edit' onclick='editRow(this)' title='button edit'>button edit</a>
<a href='javascript: void(0)' class='abutton delete' onclick='deleteRow(this)' title='button delete'>button delete</a>")
if i have to give other parameters to that editRow javascript function,for example a string something like editRow('text') can i do it and how do i format this in that template context?
Regards,
Daniel
The last second question is not related to the original topic of this support conversation, so please submit a new support ticket / forum post for it. In this way you can be sure that your query will reach the corresponding staff member in time and will be answered faster and accurately.
Kind Regards,
Vladimir Iliev
the Telerik team


Hi Neha,
I've just tested the provided by Vladimir project and it is working as expected on my end. The Delete controller method is called when a deletion is confirmed.
To be able to help you, I will need a runnable project in which the reported behavior can be replicated. Can you send me such an example?
Regards,
Petar
Progress Telerik