Hi,
i'm not sure if i should be asking this but i'll give it a try and you can feel free to say "forget it"
is there a quick way to have the Band[0] be a summery of Band[1] (parent/child)? instead of me doing it manually for each column
part of the Band[1] columns are Text data and part of them are Numbers data (represented as strings)
at the moment i am binding a dataset that has 2 tables with DataRelation between them most of the columns are the same and visually i would like the band[0] cells will be the summery of the band[1] . but i dont care about the band[0] dataset wise , i only care about the band[1]
thanks
I'm afraid I do not understand what you are asking. What exactly are you trying to do?
It sounds like maybe you want to reverse the hierarchy and show Band 1 at the top and Band 0 under that. If that's what you want, then no, you cannot do that through the grid, but you could easily adjust the Relationship in your DataSource to go the other way.
thanks for the reply Mike,
i knew i will have a problem describing what i am after
no, im dont want to reverse the hierarchy,
most , lets say all, of my data is at Band[1] (childs) and i want that Band[0] (parent) will be summery of Band[1] (childs) for visual purpes only.
for example
parent 22 <- this is band 0
child 5 <- this is band 1
child 8 <- this is band 1
child 9 <- this is band 1
as there are Summery feature for UltraGrid so what i am after is like that Summery row but as Band[0] instead of at the bottom of the band[1]
also you can think of it as Band[0] to be summery of band[1]
Hello sharik,
You could achieve the first requirement with the following code:
private void ultraGrid1_SummaryValueChanged(object sender, Infragistics.Win.UltraWinGrid.SummaryValueChangedEventArgs e) { if (e.SummaryValue.SummarySettings.Band.Key == "Band 1" && e.SummaryValue.SummarySettings.SourceColumn.Key == "Column 0 Band 1") { this.ultraGrid1.DisplayLayout.Bands[1].SummaryFooterCaption = ""; this.ultraGrid1.DisplayLayout.Bands[1].Summaries[0].SummaryDisplayArea = SummaryDisplayAreas.None; e.SummaryValue.ParentRows[0].ParentRow.Cells["Column 0 Band 0"].Value = e.SummaryValue.Value; } }
private void ultraGrid1_SummaryValueChanged(object sender, Infragistics.Win.UltraWinGrid.SummaryValueChangedEventArgs e)
{
if (e.SummaryValue.SummarySettings.Band.Key == "Band 1" && e.SummaryValue.SummarySettings.SourceColumn.Key == "Column 0 Band 1")
this.ultraGrid1.DisplayLayout.Bands[1].SummaryFooterCaption = "";
this.ultraGrid1.DisplayLayout.Bands[1].Summaries[0].SummaryDisplayArea = SummaryDisplayAreas.None;
e.SummaryValue.ParentRows[0].ParentRow.Cells["Column 0 Band 0"].Value = e.SummaryValue.Value;
}
As to your second requirement - when do you want this to happen? If your column is of type 'string' I do not see how you could do this with the summary menu. If you want the grid to show as soon as it is initialized as:
-----------------------------------------------------
parent -> Sunday, Monday, Tuesday
child -> Sunday
child -> Monday
child -> Tuesday
you would probably be forced to initialize(expand) the child rows. Please clarify if possible this.
wow , that code indeed did it .... impressive .....as all your support ...
if there is a way to hide the summery icon/button and apply summery without needing the icon, then this will indeed be very usful for me.... i mean the summery feature.
as for the second, yes this will be strings and the grid is bound to dataset so as for "when" as it loads/binds then the data will be available so i would want it to show immidiately without expanding.
i dont need to summery icon/button to be available for the user, i want to do it all at code behind.
i am going to explore this feature now and understand how it can be done by code behind
I tried to wrap up quickly a sample for you. I hope that it helps. Please let me know if there is something bothering you.
really great example !! but if i add another column of type Double and fill it with data then your code will summerize ALL child cells that are double, it does not focuse on the same column as the parent.
in my case the child columns are not exactly as parent columns
parent -> col1 col2 col3 decCol1 DecCol2 ....
child -> col1 decCol1 DecCol2 ....
when i tried it on my project it it had an offset of columns , meaning like the child summery value went into the wrong parent ( one to the left)
when i do it on the DataSet side and not the grid side , then it goes well.
thanks Boris :)
Removing the following foreach statement could help for this:
foreach (UltraGridCell cell in row.Cells)
So the code should become:
foreach (UltraGridRow row in e.Row.ChildBands["Band 1"].Rows) { //foreach (UltraGridCell cell in row.Cells) //{ switch (e.Row.Cells[0].Column.DataType.Name) { case "Decimal": { e.Row.Cells["Column 0 Band 0"].Value = int.Parse(row.Cells["Column 0 Band 1"].Value.ToString()) + int.Parse(e.Row.Cells["Column 0 Band 0"].Value.ToString()); break; } case "String": { e.Row.Cells["string"].Value = e.Row.Cells[0].Value.ToString() + ", " + e.Row.Cells["string"].Value.ToString(); break; } } //} }
foreach (UltraGridRow row in e.Row.ChildBands["Band 1"].Rows) { //foreach (UltraGridCell cell in row.Cells) //{ switch (e.Row.Cells[0].Column.DataType.Name) { case "Decimal": { e.Row.Cells["Column 0 Band 0"].Value = int.Parse(row.Cells["Column 0 Band 1"].Value.ToString()) + int.Parse(e.Row.Cells["Column 0 Band 0"].Value.ToString());
break; }
case "String": { e.Row.Cells["string"].Value = e.Row.Cells[0].Value.ToString() + ", " + e.Row.Cells["string"].Value.ToString();
break; } } //} }
Please do not hesitate to contact me if you need any additional assistance.
yes that was some of the tweeking needed :) thanks