I am using a WebHierarchicalDataGrid to group data. I have the columns and bands configured and they are displaying the data as they should.
I would like to customize the text in the group row copied and pasted the following code to thee GroupedRowInitialized event.as follows:
If e.GroupedRow.ColumnGroupedBy.Key = "StopNum" Then
If e.GroupedRow.Value = DBNull.Value Then '' Get number of items from default text 'Dim numItems As String = e.GroupedRow.Text.Substring(e.GroupedRow.Text.Length - 3, 3) 'e.GroupedRow.Text = "Reports to no one " & numItems Else Dim numItems As String = e.GroupedRow.Text.Substring(e.GroupedRow.Text.Length - 3, 3) ' Get value being grouped by Dim value As Integer = CInt(e.GroupedRow.Value) ' Get the row with EmployeeID equal to the value being grouped by from the ReportsTo column. ' This returns the row for the employee that the rows that are being grouped reports to. Dim record As GridRecord = Me.WebHierarchicalDataGrid1.Rows.FromKey(New Object() {value}) If record IsNot Nothing Then ' Get the name of the person to report to Dim name As String = (record.Items(2).Value.ToString() & " ") + record.Items(2).Value.ToString() e.GroupedRow.Text = ("Reports to " & name & " ") + numItems End If End If End If
All of the records in the bands are grouped by 'StopNum'
The problem at this point that i am having is it does not appear that the GroupedRowInitialized is firing. I am new to infragistics and and hoping that i can get some help with first figuring out why this is not firing and then configuring the custom text that i would like to appear. If i can get the grid to work the way i want i am going to upgrade to the most recent version of the ultimate subscription.
any helper would be greatly appreciated.
Hello Mike,
It seems that you have followed the following topic in our documentation, which describes how to create a custom text for the group by rows using the GroupedRowInitialized. One reason why it may not work for your gird is that your gird would have a different data source you would have to adapt the example code to your data by placing the right fields as well as column indexes.
If you have done this, could you let me know if the event triggers when you place a breakpoint, since dragging the column header to the GroupByArea should trigger the event?
Additionally I have prepared a small sample that provides a simplified version of this example presented in the documentation. On my side everything seems to behave as expected and the event fires every time a column has been dragged to the GroupByArea.
I am attaching the sample below, please test the sample on your side and let me know if you have any questions or concerns.
Regards, Ivan Kitanov
GroupByRowSample.zip
I am currently is SQL datasources and the grid datasource. This will not work using those as the datasource?
The suggestion about creating the columns and bands in code behind was in case you are setting the data source of the grid dynamically. In case you are able to define the bands and columns beforehand you can leave them like that you wouldn’t have to define them in code behind.
What I would like to suggest you is testing the sample provided above and checking if the custom text is applied to the “Name” column on your side. In case it does is it possible to adapt the sample to the way you are setting the custom text or to provide a code snipped for it so I can investigate it further.
Looking forward to hearing from you.
I have the autogenerate for both columns and bands set to false and I configured both of them using the GUI. I will try creating the columns in the code behind and see if that solves my problem.
This should work with any kind of data source that could be bound to the grid, a possible reason why this would not work is if you are using the AutoGenerateColumns property with value true and you are loading the data source dynamically, in this case I would suggest you setting the AutoGenerateColumns and AutoGenerateBands properties to false and then creating the bands and columns in code behind, thus you would ensure that the columns would be added to the columns collection and the custom text would be applied when a column is grouped.
Please let me know if you have any additional questions.