I have a sub grid which contains a single foreign key column. As such, it doesn't make sense for this grid to allow edits, just deletes and inserts. However, if I remove the edit command, the cancel button is no longer visible.
I have tried the suggestion in the post here Grid: Insert and Delete only, no update of existing records in UI for ASP.NET MVC | Telerik Forums however this does not seem to work.
I am using version v2023.2.718.
How can I remove the edit button, but keep the cancel button for inserts when using inline editing?
My grid definition is:-
<script id="subdetailsTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid< KPIDataEntryForms.Models.IndicatorBundlesToMetricsMap> ()
.Name("mapGrid_#=ID#")
.Columns(col =>
{
col.Bound(o => o.ID).Title("ID").Width(150);
//col.Bound(o => o.IndicatorBundle).Title("Bundle ID");
//col.Bound(o => o.MetricID).Title("Metric ID");
col.ForeignKey(p => p.MetricID, ds => ds.Read(r => r.Action("GetMetrics", "ScoreCards")), "MetricID", "MetricName")
.Title("Metric").Width(500);
col.Command(command => { command.Destroy().Text(" "); command.Edit().Text(" ").UpdateText(" ").CancelText(" "); });
})
.ToolBar(tb => tb.Create())
.Editable(e => e.Mode(GridEditMode.InLine))
.Events(e=>e.DataBound("hideUpdateBtn"))
.DataSource(ds => ds
.Ajax()
.Events(e => e.Error(o => gridTemplateHelper("#=ID#")))
.Model(m =>
{
m.Id(p => p.ID);
m.Field(p => p.ID).Editable(false);
})
.PageSize(15)
.Read(rd => rd.Action("RD_BundleMaps", "ScoreCards", new { BunID = "#= ID #" }))
.Create(u => u.Action("InsertBundleMap", "ScoreCards", new { BunID = "#= ID #" }))
.Destroy(u => u.Action("DeleteBundleMap", "ScoreCards"))
.Update(u => u.Action("DeleteBundleMap", "ScoreCards"))
.Sort(s =>
{
s.Add(a => a.ID).Descending();
})
)
.Pageable(p=>p.Refresh(true))
.Sortable()
.ToClientTemplate()
)
</script>
<script type="text/javascript">
function hideUpdateBtn()
{
this.table.find(".k-grid-edit").hide();
}
</script>
-
After further investigation i changed the function to:-
function hideUpdateBtn() { this.table.find(".k-grid-edit-command").hide(); }