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

[Solved] Conditional show hide Command Buttons for rows with certain value

1 Answer 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sumit
Top achievements
Rank 1
Sumit asked on 14 Mar 2013, 05:52 AM
Hi Team,

I have a scenario wherein I'm using a telerik grid with ajax. I have a command column that displays Update and Delete button. Now, I want to show the Update button for certain scenarios, say if a field is true, show the Update button, otherwise don't.
I have gone through some of your threads where you have suggested to hide a command button in JS using CSS, but I don't want that. The drawback of using this approach is that the button will still be rendered even though it is hidden. So, one can open the developer toolbar find the hidden button and change the visibility to true and hence he'll be able to see and click the command button. 
I want that the Update button should not render altogether if the condition is not satisfied. Can you please suggest something?
Here's my piece of code:
@(Html.Telerik().Grid<Campaign>()
    .LibraryGrid()
    .Name(CampaignController.IndexGridName)
    .DataKeys(d => d.Add(k => k.CampaignId))
    .ToolBar(t =>
    {
        t.AddButton("Campaign");
        t.ClearAllButton("Campaign");
    })
    .DataBinding(binding =>
    {
        binding.Ajax()
            .Select("Select", "Campaign")
            .Delete("Delete", "Campaign");
    })
    .Columns(columns =>
    {
columns.Command(commands =>
        {           
            commands.UpdateButton("Campaign");
            commands.Delete().ButtonType(GridButtonType.ImageAndText);
        }).Width(230);
        columns.WordBreakAllColumns();
    })
)

1 Answer, 1 is accepted

Sort by
0
Vince
Top achievements
Rank 1
answered on 10 Apr 2013, 12:22 AM
Hi were u able to find a solution to this?
Tags
Grid
Asked by
Sumit
Top achievements
Rank 1
Answers by
Vince
Top achievements
Rank 1
Share this question
or