I am trying to disable the delete buttons of a grid in jquery depending on certain conditions. If I check my conditions on document.ready the code to disable the buttons is not working, seemingly because the grid has not been initialized yet. I am trying to figure out how to check if it is initialized so I can do my check and then disable the buttons if necessary. I have tried it onDataBinding but that doesn't seem to do it. Here is the relevant code:
I have also tried assigning the onDataBinding in jquery instead of in the razor code but that didn't work either.
@(Html.Kendo().Grid<PASS.ViewModels.Proposals.AttachmentsViewModel>() .Name("gridAttachments") .Columns(columns => { columns.Bound(c => c.File_Name).ClientTemplate("<a href='" + Url.Action("LoadAttachment", "Proposals") + "/#= ID #'>" + "#= File_Name #" + "</a>").Title("File Name"); columns.Bound(c => c.File_Size).Title("Size"); columns.Bound(c => c.Content_Type).Title("Type"); columns.Command(command => { command.Destroy(); }).Width(90); }) .Sortable() .Events(events => events.DataBinding("onDataBinding")) .DataSource(dataSource => dataSource .Ajax() .Model(model => model.Id(c => c.ID)) .Read(read => read.Action("GetAttachments", "Proposals", new { proposalID = Model.Proposal_ID })) .Destroy(destroy => destroy.Action("DeleteAttachment", "Proposals")) ) )<script type="text/javascript">$(document).ready(function () { var formDisabled = $('#Form_Disabled').val(); if (formDisabled == "True") { $('#Files').data('kendoUpload').disable(); }})$(function () { $("#Files").data("kendoUpload").bind("success", function () { $("#gridAttachments").data("kendoGrid").dataSource.read(); })})function onDataBinding(e) { var formDisabled = $('#Form_Disabled').val(); alert(formDisabled); if (formDisabled == "True") { $('.k-grid-delete', '#gridAttachments').hide(); }}</script>I have also tried assigning the onDataBinding in jquery instead of in the razor code but that didn't work either.