Hello,
I have a question again regarding a hierarchical dataset as datasource for my ultragrid. I have on every level a checkbox column in the header and therefore in every row. This is for checking or unchecking the row for later processing later on. Unfortunately this header checkbox is only working for the level it is on, that means if I check it, it doesn't check the child rows automatically. Thus I manually programmed this functionality but it has bad performance for a higher amount of datarows. I my current test example I have 1500 rows on the first level and multiple bands which are holding lots of childrows, one of em even about 8000-12000 rows. I also need to set a headercheckbox to indeterminate if at least one datarow in the lower childlevels is not checked. And here is my problem, because therefore I have to iterate through ALL rows and have to look if it is checked. Currently I'm doing this with the example code of this:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.1~Infragistics.Win.UltraWinGrid.UltraGridRow~ChildBands.html
That takes in my example (I have single core 64bit, 2ghz, 32bit winxp, 2gb ram) almost one minute.
my question is, do you think this is normal with that mass of datarows or do you have any idea too make things differently?
here is my part of code:
Protected Function IsEveryRowChecked(ByVal Rows As RowsCollection) As Boolean For Each Row As UltraGridRow In Rows If DirectCast(Row.Cells("check").Value, Boolean) Then If Not Row.ChildBands Is Nothing Then For Each ChildsChildBand As UltraGridChildBand In Row.ChildBands If Not IsEveryRowChecked(ChildsChildBand.Rows) Then Return False End If Next End If Else Return False End If Next Return True
End Function
Greetings,
Renelope
I would recommend against selecting rows from both bands though code as the end user isn't able to do it in the UI and it might seem weird to them to have the rows selected in a way that they can't duplicate.
For the performance option, I would still advise against changing the Selected.Rows collection while iterating through it. Instead of looping through the Selected.Rows, maybe you could loop through the array of rows that is returned by GetFilteredInNonGroupByRows of the Rows collection on the grid since those are the rows that are currently selected since they were just added.
To improve performance, you may also want to build the string for the clipboard as you loop through the rows, at least for the parent rows. You could also see if calling PerformAction on the grid and passing in UltraGridAction.Copy meets your needs for adding data to the clipboard.
Thank you for the suggestion, but my requirement is bit different needed synch between the UI display and the performing of operation.
I have to copy the information to the clipboard at the same time I have to mimic the user that these are the selected rows that are being copied.
For providing a clarity for the user I am selecting all the rows and copying them to the clipboard. I am extracting data from all the selected rows to build a string.
The logic provided seems as though you are selecting all of the rows in the grid. If the only reason is to put the data in the clipboard, do you really need to select the rows in the grid?
You could build your own string to set the clipboard data to without needing to select the rows. There is logic in the microsoft forums to do this for a dataset that you could use as a guide on how to build the string. Note that it might be more efficient to use the ListObject of the row to build the sting for each row than to access the data from the UltraGridRow or UltraGridCell objects.
Hi Halama, Mike, We are using UltraWingrid (Infragistics v10.3) for our application. I have to copy all the selected rows information to a clip board, this should spawn across the bands (we have only 2 bands right now).
It sounds like what you really want here is more of a CheckBox where the parent checkbox reflects the parent, rather than selection. If you are not using any grid-specific features like filtering, summaries, or exporting, you might be better off using am UltraTree control instead of UltraGrid and then using the SynchronizedCheckBox Style for your nodes.