Conditional DetailTemplateItemDataCell visibility

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

    Posted 17 Oct 2016 Link to this post


    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?



  2. Eyup
    Eyup avatar
    3962 posts

    Posted 20 Oct 2016 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:

    I hope this will prove helpful.

    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.
Back to Top