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

How to hide a cell (not a column) in radgrid prerender?

1 Answer 653 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Balaji
Top achievements
Rank 1
Balaji asked on 16 Oct 2015, 07:45 AM

I worked in radgrid itemdatabound for hiding cells, but how can i do it in radgridprerender event?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 21 Oct 2015, 06:20 AM
Hello Balaji,

Removing entire cell in the grid is not recommended as it would cause the rest of the cells in the row to be misaligned.

If you would like not to display a specific value in a column you can use one of the the following approaches:

using ItemDataBound event:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
         
        if (dataItem["ColumnUniqueName"].Text == "some value")
        {
            dataItem["ColumnUniqueName"].Text = "";
        }
 
    }
}


using PreRender event:

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem dataItem in RadGrid1.Items)
    {
        if (dataItem["ColumnUniqueName"].Text == "some value")
        {
            dataItem["ColumnUniqueName"].Text = "";
        }
    }
}




Regards,
Viktor Tachev
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
Tags
Grid
Asked by
Balaji
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or