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

RadGrid Dyanmic CommandItemSettings

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaveh
Top achievements
Rank 1
Kaveh asked on 06 Feb 2012, 05:35 AM
Hello -

I have a RadGrid with a Master/Detail relationship.  For some detail table views, I would like to dynamically show or hide the "Add New Record' button *only* for that detail table view.  I'm not sure how to correctly do this, as every way I try seems to modify the CommandItemSettings for *every* detail table view (it will hide/remove the button for all detail tables).  I would like to be able to expand multiple items, where some detail table views show the "Add New Record" button, and some don't, depending on custom logic. 

I really hope this is possible!  

Thanks very much.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2012, 06:11 AM
Hello Kaveh,

One suggestion is you can check for the condition and show CommandItemDisplay as shown below.
C#:
if (e.DetailTableView.Name == "DetailTable1")
{
e.DetailTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
}

-Shinu.
0
Abhishek
Top achievements
Rank 2
answered on 06 Feb 2012, 07:06 AM
Hello Kavesh,
One suggestion from my side to show hide "Add New Record" only you can do using below code:
For Main RadGrid:
           if (e.CommandName == RadGrid.InitInsertCommandName || e.CommandName == RadGrid.EditCommandName)
           {
               rgCollectorClass.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
               rgCollectorClass.AllowSorting = false;
           }
           else
           {
               rgCollectorClass.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
               rgCollectorClass.AllowSorting = true;
           }

For DetailTable:
if (e.DetailTableView.Name == "MyDetailTable")
{
e.DetailTableView.CommandItemSettings.ShowAddNewRecordButton = False;
}

I have used this my project to show and hide Add new Button. Try the above logic.


Regards,
Abhishek K
Tags
Grid
Asked by
Kaveh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Abhishek
Top achievements
Rank 2
Share this question
or