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

Removing/Hiding a GridItem inside of _ItemCreated

1 Answer 23 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Dmitri asked on 16 Dec 2015, 02:10 PM

I have a dynamically loaded grid (automatic column generation, data table as a source) and currently I use the code below to catch the rows as they are created and compare their content to the previous row to track changes in the data. If nothing changed i want to hide the row from the grid. Based on everything i have read the code below should work properly and it does for highlighting column changes BUT for some reason its ignoring the e.Item.Visible setting and still showing rows that I have set to hidden. Thanks in advance!

01.System.Data.DataTable dt = null; rowCnt = 0;
03.List<int> colsNotToTrack = new List<int>();
04.protected void rgResults_ItemCreated(object sender, GridItemEventArgs e)
06.    if (compareLines && e.Item is GridDataItem)
07.    {
08.        if (rowCnt > 0)
09.        {
10.            bool changed = false;
11.            for (int i = 2; i < e.Item.Cells.Count; i++)
12.            {
13.                if (colsNotToTrack.Contains(i))
14.                    continue;
15.                if (dt.Rows[rowCnt][i - 2].ToString() != dt.Rows[rowCnt - 1][i - 2].ToString())
16.                {
17.                    e.Item.Cells[i].BackColor = System.Drawing.Color.LightSalmon;
18.                    changed = true;
19.                }
20.            }
21.            e.Item.Visible = changed;
22.        }
23.        rowCnt++;
24.    }

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 21 Dec 2015, 08:43 AM
Hi Dmitri,

Please try using Display property instead of Visible. This should hide the rows correctly on ItemCreated event handler.

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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question