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

2 posts, 1 answers
  1. Balaji
    Balaji avatar
    8 posts
    Member since:
    Jun 2015

    Posted 16 Oct 2015 Link to this post

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

     

  2. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2357 posts

    Posted 21 Oct 2015 Link to this post

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