Hi,
I use EditorTemplates in Grids to change entries in cells. By pressing the check-icon a function is called.
It works fine as long as the grid has set:
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple))
If the MultiSelect-Mode is not set, the click event on the span is not detected. How can I implement this for Single-Selection Mode?
And is it possible to generate a generic EditorTemplate to be used on different grids?
Thanks
Christine
--------------------------------------
Here the sources:
The grid:
<script id="suppress-text-template" type="text/x-kendo-template">
<div id="suppress-text-container" style="height:100%;width:100%;">
@(Html.Kendo().Grid<collact.admin.Models.Ticket.TextItemModel>()
.Name("SuppressTextGrid")
.Columns(columns =>
{
columns.Bound(p => p.EntryId).Editable("returnFalse");
columns.Bound(p => p.Entry).Title("Texteintrag").EditorTemplateName("Ticket/GridSuppressEdit");
})
.HtmlAttributes(new { style = "height: 100%;" })
.Sortable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(e => e.Edit("sigGridSuppress_edit"))
.Scrollable(scr => scr.Height(430))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.EntryId))
.Read(read => read.Action("ReadListData", "Ticket"))
)
.Filterable()
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple))
.PersistSelection(true)
.Resizable(resize => resize.Columns(true))
.ToClientTemplate()
)
</div>
</script>
The script setting the text of the Textbox in the EditorTemplate:
function sigGridSuppress_edit(e) {
var editForm = e.container;
var model = e.model;
editForm.find("#EntryId_entryid_edit").val(model.EntryId);
editForm.find("#Entry_entrysuppress_edit").val(model.Entry);
}
The EditorTemplate:
<table><tr>
<td>
@(Html.Kendo().TextBox().Name("entrysuppress_edit"))
<div style="display:none">
@(Html.Kendo().TextBox().Name("entryid_edit"))
</div>
</td>
<td style="border:none;padding:4px;width:36px">
<span class='k-icon k-i-check-outline k-icon-36' style="float:left;display:block;display:inline-block" onClick="editSuppressText()" />
</td>
</tr>
</table>