Conditional DetailTemplateItemDataCell visibility

2 posts, 0 answers
  1. Matthew
    Matthew avatar
    11 posts
    Member since:
    Feb 2015

    Posted 17 Oct Link to this post

    Hi,

    I am using the DetailTemplateItemDataCell to put detailed information in per grid item.

    However it is not used in all cases. When we want just the row itself I would like to be able to hide the detail template item but have not found this trivial.

    I have tried .visible = false which doesn't render the detail cell but the row is still rendered and takes up the same amount of space.

    I have also tried using DetailTemplateItemDataCell.parent.visible but this doesn't work either as it doesn't map to the row element.

    Using css to set display none doesn't help either.

     

    I am thinking that I am going to have to write some jquery to select the detail item data cells that I want to hide (based upon their content) then hide their parents. I was however hoping that there was an easier way to set this on the server side.

    Any suggestions?

    Thanks,
    Matt

     

  2. Eyup
    Admin
    Eyup avatar
    3008 posts

    Posted 20 Oct Link to this post

    Hi Matt,

    You can achieve this requirement using the following approach:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            if (item.ItemIndex % 3 == 0)
            {
                item.DetailTemplateItemDataCell.Visible = false;
            }
        }
    }

    And for accessing the item data values, you can use the approach demonstrated in this section:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-raw-field-data-and-key-values

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top