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

Conditional DetailTemplateItemDataCell visibility

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 17 Oct 2016, 05:56 AM

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

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Oct 2016, 05:29 AM
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.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or