RadGrid Dyanmic CommandItemSettings

3 posts, 0 answers
  1. Kaveh
    Kaveh avatar
    5 posts
    Member since:
    Dec 2011

    Posted 05 Feb 2012 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Feb 2012 Link to this post

    Hello Kaveh,

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

  3. DevCraft R3 2016 release webinar banner
  4. Abhishek
    Abhishek avatar
    45 posts
    Member since:
    Jul 2012

    Posted 06 Feb 2012 Link to this post

    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;
                   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.

    Abhishek K
Back to Top