This is a migrated thread and some comments may be shown as answers.

[Solved] Multiple custom commands in one column and couldn't able to define a conditional custom command

1 Answer 264 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 22 Nov 2014, 12:48 AM
I am using Kendo UI grid to render the grid data. I have a column with multiple custom commands(4 custom commands exactly). one of the custom command needs to be conditional custom command i.e. It is functionality(or appearance) depends up on the row data being rendered.

I couldn't get that defined. I tried template approach but the default data is not having the row data. I defined field and template but still I am not getting the field value. Could you somebody help me to solve this problem.

My DataSource is coming from the asp.net web api service via ajax.

Thanks

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 25 Nov 2014, 11:22 AM
Hello Rob,


You could include the command in the Grid configuration for each row and then use the dataBound event of the Grid to remove it for the ones that it is not needed. Each command receives a CSS class following the pattern k-grid-commandname. You could use this class to retrieve the command for the specified row.
E.g.
function dataBound(e) {
    var grid = this;
 
    grid.tbody.find("tr").each(function () {
        var model = grid.dataItem(this);
 
        if (model.EmployeeID > 100) {
            $(this).find(".k-grid-myCommand").remove();
        }
    });
}

I hope this information helps.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or