Grid Detail Table CommandItem

2 posts, 0 answers
  1. Matthew
    Matthew avatar
    3 posts
    Member since:
    Sep 2014

    Posted 18 Nov 2015 Link to this post

    Hi all,

    How would I go about showing/hiding the CommandItem for a detail table from an external button in the code behind.Our webapp has a set of "new", "edit" & "save" buttons created in a masterpage which are enable/disabled based on the users access rights. I want to be able to allow a user to create a new record within a radgrid at both the master table and detail table level. I can enable the CommandItem for the master table but i cant do it for the detail tables. I've tried looping through the NestedTableView items but on a rebind the grid doesn't change

     

    Thanks Matt

     

     

  2. Eyup
    Admin
    Eyup avatar
    3841 posts

    Posted 23 Nov 2015 Link to this post

    Hi Matt,

    Generally, you can traverse the GridTableViews to achieve this requirement:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/how-to/hiding-the-expand-collapse-images-when-no-records

    Alternatively, you can enable all command items:
    <telerik:GridTableView ...
        CommandItemDisplay="Top" Name="OrderDetails">

    and alter their visibility depending on some global variable/condition:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "OrderDetails")
        {
            GridCommandItem commandItem = (GridCommandItem)e.Item;
            commandItem.Visible = false;
     
            // commandItem.Display = false;
            // commandItem.Style["display"] = "false";
        }
    }

    Hope this helps.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top