We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Expand button reset

Hi,

I have a grid bound to a custom collection. All of the rows have the standard "+" to expand.

If the user expands a row where the objects child collection is empty the "+" disappears - as you would expect. However some processing in the app can add children to the node - and I need to allow the users to expand the row again.

The only way I have found of doing this is to do a complete Refresh - which I really want to do.

Any ideas anyone?

6 Replies

AD Administrator Syncfusion Team January 12, 2007 04:48 AM UTC

Hi Stuart,

To set minus the expansion indicator when no children are present in the parent row of a hierarchical grid, you can handle the CellDrawn in the grid.

In the CellDrawn event handler, you check whether the row has a child list, and if it does, you check if the child list has members. The tricky part is that you can only getthe proper child count if the node is expanded. So, anytime there is an unexpanded node, the code does a 'silent' expand. Please refer to the attached sample for implementation.

Sample : PreventPlusSign.zip

Best Regards,
Haneef


SG Stuart Grimsell January 12, 2007 10:50 AM UTC


Haneef,

Sorry I want to do the complete opposite. I have added a child to a record that doesn't have the expand button indicated. I now want to give the user the option of expanding it - or doing it programmatically.


SG Stuart Grimsell January 15, 2007 05:15 PM UTC

Anybody got any input?


AD Administrator Syncfusion Team January 16, 2007 09:58 PM UTC

Hi Stuart,

Please try the attached sample and let me know if you are looking something different.
ChildTableAddNewRow.zip

Best Regards,
Haneef

Note: ParentID > 11 doesn't have the child row.


SG Stuart Grimsell January 24, 2007 04:10 PM UTC


I have tried playing around with the samples as given and I am afraid they don't help much at all.

The "preventplussign.zip" is OK - but the issue still remains. A user clicks on a [-] and then a child gets added - there is no way to expand the node.

The ChildTableAddNewRow.zip works ( after a fashion ). I have removed some of the spurious code in the sample and have shown that it is the call to DataSet.AcceptChanges() that puts the [+] signs back in. I guess this just means that the dataset is sending a "reset" event into the grid. This also resets all the exapand states.

So it seems that the only way I can get the [+] symbol back is to refresh the grid ( which I would then have to do after every child add - not good ) - and manage all the expand states for the rows.

Surely there must be a better way to do this.


SG Stuart Grimsell January 26, 2007 03:18 PM UTC

Solution found - but more info required.

Haneef,

I have managed to solve my problem and although I don't really like the solution it works.

Unfortunatly my solution requires me to do some paint work in CellDrawn ( like the sample you gave ). This is complicated by the fact that we are showing tree lines etc.

I have a set of parameters for areas to draw into, line sizes etc but am worried that these values are only correct for certain visual styles etc. I can't see anyway of getting information from the grid about the size and location of the [+] button or anything else so that I can be more dynamic and "safer" about my drawing code.

Any ideas how I can get the metric information about this drawing stuff?

Thanks

Stuart

Loader.
Live Chat Icon For mobile
Up arrow icon