Hello,
I have a webhierarchicaldatagrid withy only 2 levels:
<ig:WebHierarchicalDataGrid ID="GridSampleSize" runat="server" AutoGenerateBands="False" AutoGenerateColumns="False" EnableAjax="False" Height="450px" Width="746px" DataKeyFields="MAINKEY,SAMPLESIZE,PHASE" OnInit="GridSampleSize_Init"> <Columns> <ig:BoundDataField DataFieldName="PHASE" Key="PHASE"> <Header Text="<%$ Resources:Labels, lblPHASE %>" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="APPROVED" Key="APPROVED"> <Header Text="APPROVED" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="REJECTED" Key="REJECTED"> <Header Text="REJECTED" /> </ig:BoundDataField> </Columns> <Bands> <ig:Band AutoGenerateColumns="False" DataMember="dsMeasSampleSizeEnfant2_DefaultView" Key="dsMeasSampleSizeEnfant2_DefaultView"> <Columns> <ig:BoundDataField DataFieldName="POINT" Key="POINT" Width="50px"> <Header Text="<%$ Resources:Labels, lblPOINT %>" /> </ig:BoundDataField> <ig:BoundDataField Width="250px" DataFieldName="DESCRIPT" Key="DESCRIPT"> <Header Text="<%$ Resources:Labels, lblDESCRIPT %>" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="TOLERANCE" Key="TOLERANCE" Width="50px" DataType="System.Decimal"> <Header Text="<%$ Resources:Labels, lblTOLERANCE %>" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="SIZE" Key="SIZE" Width="50px" DataType="System.Decimal"> <Header Text="SIZE" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="SUPVAL" Key="SUPVAL" Width="140px" DataType="System.Decimal"> <Header Text="<%$ Resources:Labels, lblSUPVAL %>" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing Enabled="true" EditModeActions-EnableF2="true"> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="POINT" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="DESCRIPT" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="TOLERANCE" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="SIZE" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="SUPVAL" ReadOnly="true" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:Band> </Bands></ig:WebHierarchicalDataGrid>
My grid is bound in code behind.
I would like to have some cells in red, regarding this condition in my second level:
if (supval - size)>tolerance then supval cell should be in red..
I am trying to do it in client side, because I would like to have it on live (so when the value in supval is changed)
Do you have some ideas to do it?
Thanks for your help.
Hi Radoslav,
Thanks for your quickly help.
For the init, I have no more problems, thanks for your sample.
I have some more problems for the rowExpanded event:
In order to handle rowExpanded event, my whdg needs to have the property "EnableAjax" set to "true".
But when this property is set to "true", I have a runtime error: "Sys.ArgumentException: Cannot deserialize. The data does not correspond to a valid JSON" if I try to expand a band level.
I read in a post that this error was due to the "EnableAjax" property, and yes, when it is set to "false", I could expand my levels without any problems. But how could I combine the EnableAjax=false with rowExpanded event?
Thanks again for your help.
Regards
Damien
I would suggest the following approach :
if you would like on initial load the grid to color a given cell you can handle the initialize client-side event handler like so:
89
90 function gridInit(sender, args) {
91 for (var i = 0; i < sender.get_rows().get_length(); i++) {
92
93 var row = sender.get_rows().get_row(i);
94
95 for (var j = 0; j < row.get_cellCount(); j++) {
96
97 var cell = row.get_cell(j);
98
99 if (cell.get_text() == "Item 1") {
100 cell._element.style.backgroundColor = "red";
101 }
102 }
103 }
104 }
If you would like to handle this on the child band level you can handle RowExpanded event handler and then to pass through the cell like above.
90 function rowExpanded(sender, args) {
91 // debugger;
92 var sender = args.get_row().get_rowIslands()[0];
93 for (var i = 0; i < sender.get_rows().get_length(); i++) {
95 var row = sender.get_rows().get_row(i);
97 var is = row.get_rowIslands();
98 // debugger;
99 for (var j = 0; j < row.get_cellCount(); j++) {
100
101 var cell = row.get_cell(j);
102 Sys.Debug.trace(cell.get_text());
103 if (cell.get_text() == "Item 30") {
104 cell._element.style.backgroundColor = "red";
105 }
106 }
107 }
108 }
Hope this helps you.