Command column visibility

2 posts, 0 answers
  1. Kabir
    Kabir  avatar
    1 posts
    Member since:
    Oct 2012

    Posted 23 Oct 2012 Link to this post


    I have a requirement where a command column (delete) needs to be visible for a row only if a column value in the row meets certain criteria.
    .Columns(columns =>
    columns.Bound(o => o.PitID).Visible(false);
    columns.Bound(o => o.VersionID).Width(50);
    columns.Bound(o => o.VersionNote);
    columns.Bound(o => o.ReleasedBy);
    columns.Bound(o => o.ReleasedDateDisplay);
    columns.Bound(o => o.Deletable).Visible(false);
    columns.Command(command => command.Custom("Select").Click("showIssue")).Width(100).Title("Select");
    columns.Command(command => command.Custom("Delete").Click("Delete")).Width(100).Title("Delete");

    The delete command needs to visible only if  Deleteable is true.

  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 26 Oct 2012 Link to this post

    Hello Kabir,

    Basically such visibility depending on a field of the model is not supported out-of-the box. 

    I assume you are using Ajax binding. If so to achieve your goal you can use the dataBound event of the Grid and cycle through all the items the Grid currently displays. For each of the items which meet your requirement you can find the related row with the uid property and hide the delete button.
    Here is an example:
    <script type="text/javascript">
        function dataBound(e) {
            $.each(this.dataSource.view(), function () {
                if (this.IsDeletable) {
                    $('[data-uid=' + this.uid + ']').find('.k-grid-delete').hide();

    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top