I've got a sub-grid, which needs to allow records to be inserted, dependant on a value in the parent record.
I've got an onBound handler, which gets passed the subGrid name, but what do I need to do to hide the create button in the toolbar?
The toolbar is defined here:-
@(Html.Kendo().Grid<SystemsHelpDesk.Models.View_Support_Action>() .Name("ActionGrid_#=LogID#") .Events(e => e.Edit("onEdit")) .Columns(columns => { columns.Bound(o => o.ActionID).Title("ID"); columns.Bound(o => o.ActionDate).Title("Date").Format("{0:g}"); columns.Bound(o => o.CategoryDescription).Title("Category"); columns.Bound(o => o.ActionDesc).Title("Details"); columns.Bound(o => o.UserName).Title("User"); }) .ToolBar(commands => commands.Create().Text("Add Action")) .Events(e => e.DataBound(@<text> function(e){onSubBound(e,"ActionGrid_#=LogID#",#=Resolved#)}</text>)) .Editable(editable => editable .Mode(GridEditMode.PopUp)) .DataSource(dataSource => dataSource .Ajax() .Events(e => e.Error(@<text> function(e){subError(e,"ActionGrid_#=LogID#")} </text>).Sync("ActionSync")) .Model(m => m.Id(p => p.ActionID)) .PageSize(10) .Read(read => read.Action("RD_Actions", "Home", new { LogID = "#= LogID #" })) .Create(create => create.Action("InsertAction", "Home", new { LID = "#= LogID #" })) .Update(update => update.Action("UpdateAction", "Home")) .Destroy(delete => delete.Action("DeleteAction", "Home")) ) .Pageable(p => p.Refresh(true)) .ToClientTemplate() )I can pass the Grid name and the value of the Boolean field that determines if records should be able to be added, but I'm at a loss at how to hide the button. I have tried:-
function onSubBound(e,gridName,Flag) { // alert(gridName); //alert(Flag); var grid = $(document.getElementById(gridName)).data("kendoGrid"); $(grid).find("k-grid-toolbar").hide(); }But this doesn't work.
How can I hide the button when I need to?
Thanks
