Reputation: 1
I'm using kendo grid for adding and updating my values.
Update button is enable for all rows default, but I just want to enable the button based on the column?
Upvotes: 0
Views: 573
Reputation: 15155
If you are using the mvc fluid api to configure your grid columns then try this solution.
columns.Bound(p => p.MyModelID).Title("My Button Column").Sortable(false)
.Width(120)
.ClientTemplate("#if(MyModelFieldShowButton){#" +
"<button onclick='myButtonClick(#=MyModelID#)' tabindex='0' class='k-button k-button-icontext' id='btnMy#=MyModelID#' role='button' aria-disabled='false' type='button' data-role='button'><span class='k-icon k-i-redo'></span>My Button Text</button>" +
"#}else{#" +
"<button onclick='myButtonClick(#=MyModelID#)' tabindex='0' class='k-button k-button-icontext' id='btnMy#=MyModelID#' role='button' aria-disabled='false' type='button' data-role='button' disabled><span class='k-icon k-i-redo'></span>My Button Text</button>" +
"#}#"
)
.HeaderHtmlAttributes(new { title = "Queue the notification for delivery.", style = "text-align:center" }
);
Upvotes: 0
Reputation: 616
on Databound event you can remove Edit button for every row of kendo grid based on you condition
try with this code
function onDataBound() {
//Selects all edit buttons
$("#Grid tbody tr .k-grid-edit").each(function () {
var currentDataItem = $("#Grid").data("kendoGrid").dataItem($(this).closest("tr"));
//Check in the current dataItem if the row is editable
if (currentDataItem.isEditable == true) {
$(this).remove();
}
})
Upvotes: 1