Kishor Kumar S
Kishor Kumar S

Reputation: 1

How do I enable update button in kendo grid based on column value?

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

Answers (2)

Ross Bush
Ross Bush

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

LateshtClick.com
LateshtClick.com

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

Related Questions