This question is locked. New answers and comments are not allowed.
Hello,
I've added a custom command button to the grid as follows:
Now I want to show this column only when the property 'IsLockedOut' on the item is true. So I need to do something like
.Hidden(IsLockedOut == false)
But I don't know how to get to the IsLockedOut property in that scope?
I've added a custom command button to the grid as follows:
columns.Command(commands =>
{
columns.Bound(c => c.UserName)
.ClientTemplate("<a href=\"#\" onclick=\"javascript: LockAndRefresh('<#= UserName #>'); return false;\" class=\"t-button\">Unlock</a>")
.Title(String.Empty)
.Width(103);
commands.Delete().ButtonType(GridButtonType.ImageAndText);
}).Width(103);
Now I want to show this column only when the property 'IsLockedOut' on the item is true. So I need to do something like
.Hidden(IsLockedOut == false)
But I don't know how to get to the IsLockedOut property in that scope?
6 Answers, 1 is accepted
0
Hello,
where hidden css class has following declaration:
Rosen
the Telerik team
I suspect you want to hide the button in the cell, as you cannot hide the entire column base on a current record's value due to the fact that usually this value is different for each record therefore it can be either visible or not. If this is the case you may hide the button with similar to the following code:
.ClientTemplate("<a href=\"#\" onclick=\"javascript: LockAndRefresh('<#= UserName #>'); return false;\" class=\"t-button <#= IsLockedOut? 'hidden' : '' #>\">Unlock</a>")where hidden css class has following declaration:
.hidden{ display:none;}
Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Datamex
Top achievements
Rank 2
answered on 18 Apr 2011, 01:29 PM
Sounds like a solution, but isn't there anything I can do to prevent it from rendering alltogether? Rendering it and then hiding seems a bit dirty.
0
Hi,
Rosen
the Telerik team
You may expose a single property of the ViewModel which to determine if the columns should be visible or not.
All the best,Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Datamex
Top achievements
Rank 2
answered on 18 Apr 2011, 03:42 PM
That would hide the entire column, that's not what I want. I want to only prevent some of the buttons from rendering alltogether.
0
Hi Datamex,
Rosen
the Telerik team
I'm afraid that this is not possible if you are using ajax binding.
All the best,Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Morgan
Top achievements
Rank 1
answered on 06 Apr 2012, 01:12 PM
One tip when trying the solution indicated here. The styles for the 't-button' class will cascade and override your hidden class in some cases. However, if you mark your style with the '!important' attribute as shown here, it will then work as intended.
As for the solution being a little dirty... I'll paraphrase.. if it's dirty, and it works, it's not dirty ;)
Morgan
.hidden{ display: none !important;}As for the solution being a little dirty... I'll paraphrase.. if it's dirty, and it works, it's not dirty ;)
Morgan