I have a Band 0 with n rows. It has the Childband Band 1 with n rows.
If I want to collapse the Band 0 on some condition, It doesn't work well. No bands are getting collapsed.
I do have a e.Layout.Rows.ExpandAll() in InitializeLayout event.
And am adding the following code in RowInitialize Event
if(e.Row.Band.Index == 0)
{
if(Condition)
e.Row.CollapseAll()
}
This code doesn't work. Its not doing anything.
Have you tried going at it in the opposite direction?
I have a similar setup but I don't call the expand all routine instead I only expand the rows meeting the criterial to be expanded.
Just my two cents,
-Ian
I know that the opposite direction works.
But according to my conditions to be applied for collapsing the row would be difficult if I go in the opposite direction.
My initializerow routine I mentioned is similar to this:
switch(e.Row.Band.Index)
case 0:
//Expand Band By Default
e.Row.Expanded = true;
break;
case 1:
//Calculate Stuff & Process Some Data
//Unexpand Parent Row By Default
e.Row.ParentRow.Expanded = false;
case 2:
//Calculate Stuff & Process Data
default:
//Do Nothing
I am almost thinking I hit the same scenario you hit but was able to get the parent band (0) to unexpand by processing my conditions when the child band (1) and then unexpanding the parent band(0)
Best of luck if it helps,
I wrote this in the Initialize row event:
if(e.Row.Band.Index == 1) //child band
//Checking the condition on band0 i.e the parent row
if (e.Row.ParentRow.Cells["Coulmn1"].Value.Equals("Condition 1"))
e.Row.ParentRow.ExpandAll();
//Checking the second condition on band0 i.e the parent row
if (e.Row.ParentRow.Cells["Column1"].Value.Equals("condition 2"))
//here am trying to loop through all the child rows, but only one single row is looping for number of child row times. As the row initialize event fires only the single row at a time.
for (int i = 0; i < e.Row.ParentCollection.Count; i++)
//Conditions to be satisfied. I have multiple conditions to be satisfied here.
According to my understanding, Initialize Row event is not the correct event where the code need to be placed.
How can I resolve this?
Any Idea how to resolve the issue??
I wanted the child rows to be collapsed/ Expanded when the form is loaded.
Any help would be appreciated.
Thanks.
If the multiple conditions are satisfied in the loop this is where you want to unexpand the parent row right?
Are you able to access your dataset from the initialize row event (or store it off prior to setting the datasource)? If so you should be able to loop through that instead of the Row.Parent.Collection and do your secondary calculations against it.
Hi,
It think you may be making an incorrect assumption here that the InitializeRow event fires after the InitializeLayout event. This is not necessarily the case. IntiializeRow may fire both before and after the InitializeLayout.
So my advice would be to use InitializeRow exclusively and set the Expanded state of the row to either true or false depending on whether the condition is true or not.
You could limit the code in InitializeRow to when e.ReInitialize is false so that you only do this the first time the row is Initialized, since I am guessing you probably only want this to happen once.