We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Finding Rows and their summaries

I''m currently implementing the following code to find detail records meeting certain criteria and adding the rows to the grid''s selected records (this code came from you guys in these forums - thx): foreach(Record r in grid.Table.Records) { strCellValue = r.GetValue(strFilterColumn).ToString(); if(strCellValue == textFindValue) { if(!grid.Table.SelectedRecords.Contains(r)) { grid.Table.SelectedRecords.Add(r); } }//end if(strCellValue == strFilterText) }//end foreach Now my requirements have changed. When I find the first record that meets the criteria passed in, I may need to highlight that detail row''s summary row. I would need to do this if the column (strFilterColumn) is what the detail record''s summary column''s category is. For example: My grid is grouped by column X. I need to find the first record where X = "ABC". When I locate the first record, I need to find that detail record''s summary row. If the grid''s lowest group by category equals the find column (column X in this example), I need to highlight that summary row or add it to the grid.Table.SelectedRecords collection. In addition, I need to be able to allow a user to find the next instance and repeat the cyle above in an interactive way. Thanks

1 Reply

AD Administrator Syncfusion Team February 11, 2005 09:09 PM UTC

Anthony, Based on earlier conversations I assume you have custom GroupingEngine where you override Group and you use summaries in captions. When you find a record you can set a flag in the parent group indicatting that a detail row meets the criteria. Then you override QueryCellStyleInfo and in that event handler you check if a summary row is queried. In that case you can check the parent group whether the mentioned flag was set and in that case change the backcolor of the summary row. Code: - Getting the parent group, e.g. when your Group group = record.ParentGroup; if (group is MyCustomGroup) ((MyCustomGroup) group).HighlightSummary = true; else if (group is MyCustomChildTable) ((MyCustomChildTable) group).HighlightSummary = true; In your MyCustomGroup and MyCustomChildTable classes you add a HighlightSummary flag. A QueryCellInfo overide can look like this: private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { Element el = e.TableCellIdentity.DisplayElement; if (el is CaptionRow) { bool highlight = false; Group group = el.ParentGroup; if (group is MyCustomGroup) highlight = ((MyCustomGroup) group).HighlightSummary; else if (group is MyCustomChildTable) highlight = ((MyCustomChildTable) group).HighlightSummary; if (highlight && e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell) { e.Style.BackColor = Color.Red; // your highlight color } } } Stefan

Live Chat Icon For mobile
Up arrow icon