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

Command column visibility

1 Answer 375 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kabir
Top achievements
Rank 1
Kabir asked on 23 Oct 2012, 03:07 PM
Hi

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.

thanks

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 26 Oct 2012, 10:22 AM
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();
            }           
        })
    }
</script>


Regards,
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!
Tags
Grid
Asked by
Kabir
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or