Hello,
I am using WebHierarchicalDataGrid v11.2. In my grid I need to apply style sheet to the child band columns. The header, footer as well as cells of the child band columns should be in different color according to the style sheets. In normal case when I do not have any child band columns I'm able to apply the style sheet the following way,
grdGrid2.Rows(0).Items(0).CssClass = "StyleSheet"
But in case when there are child bands present, I am not even able to access grdGrid.Rows(0). Here the count of rows equals to 0.
Also I am creating grid columns dynamically at run time.
I need to apply style sheet to child band as well as parent band columns. What is the way to achieve this? Please help.
Thanks
Amruta D
Hi Amruta D,
Thank you for posting in the community.
In this scenario I would suggest that you use the InitializeRow server side event in order to implement your logic. Note that you can check which band a row belongs to using something similar to:
As per styling your child bands, I suggest that you make use of the RowIslandPopulated event. You may find additional useful information relevant to your scenario regarding styling and customization of WebHierarchicalDataGrid at:
http://forums.infragistics.com/forums/p/61686/312344.aspx
Please let me know if this helps.
Hello Petar,
Thanks for the immediate reply. I tried applying css through RowInitialize event and it works perfectly fine.
But in my grid I have around 100 child band columns to display. And alternately the columns have different colors assigned. So in intializeRow event I'll have to write a loop for columns too. And that I guess would degrade the performance of the page (Though I'm not sure about it). I already have a loop of data set columns to create bound columns in the grid.
If I apply the style sheet the following way it does not work.
grdGrid.Bands(1).Columns(1).CssClass = "StyleSheet"
Just in case, do I have any other option apart from RowInitialize event? Please help.
Amruta
Hello Petar, Thanks for the immediate reply. The code snippet you suggested does not work with my grid. As you said it might be the issue of bands, I'm not sure though. I've my code written as,For Each col2 In ds.Tables(0).Columns Dim boundField As BoundDataField boundField = New BoundDataField boundField.DataFieldName = col2.ColumnName boundField.Key = col2.ColumnName boundField.Header.Text = col2.ColumnName grdGrid.Bands(0).Columns.Add(boundField) Next Dim col As New DataColumn For Each col In ds.Tables(1).Columns Dim boundField As BoundDataField boundField = New BoundDataField boundField.DataFieldName = col.ColumnName boundField.Key = col.ColumnName boundField.Header.Text = col.ColumnName grdGrid.Bands(1).Columns.Add(boundField) NextThis is how I append columns to the grid. Also with this I can access all the columns of parent as well as child band using grdGrid.Columns(i) and grdGrid.Bands(1).Columns(i) respectively. But that does not apply any feature to that column.For example,grdGrid.Bands(1).Columns(1).Hidden = truegrdGrid.Bands(1).Columns(2).CssClass = "StyleSheet_Name"Both these things do not work. So then there is no use of creating boundFields in the grid.
How to apply style sheet then?
Hi Amruta,
Thank you for your reply.
It appears as if you are adding and attempting to access 2 bands at the root level of your grid (grdGrid.Bands(1)). Can you ensure that bands and columns are added according to the discussed at:
http://community.infragistics.com/forums/p/61591/311743.aspx
I am doing exactly the same as per the link you provided. The bands and columns are added that way.
I am attaching a sample demonstrating a grid with programmatically generated bands and columns and custom styling applied to its child band. Below is some sample code illustrating two apporaches for applying CSS classes:
Hope this helps.
Please feel free to contact me if you have any further questions regarding this matter.