My application has a navigable UltraWinTree in the left pane and an UltraGrid in the right pane thatshows the selected tree node.Let's say I have a groups table, a computers table and a ComputerGroups table that shows the M2M relationship between computers and groups.And there are some other tables I want to show in the child sub bands of a computer row so I am using a BindingSource tied to a DataSet so that I can drill down into a computer grid row and show the child sub bands. When a group tree node is selected I call UltraGrid.SetDataBinding with the BindingSource (my dataset) and the computers table name and use a grid_FilterRow event to decide what rows to show based on the tree node group name - e.g. show only the computers in whatever group is selected in the tree rather than all computers. Or in a different node, perhaps only the groups for the computer that is selected.My question is - how do I capture the row delete such that the row is not actually deleted but rather I can just delete the relationship from the ComputerGroups table? Is this possible? Is my overall strategy ill thought? AfterRowDeleted seems too early and BeforeRowDeleted seems too late.I could use some advice on the general strategy as I'm not enthused about having to filter the rows shown in a grid view rather than just give it an already subsetted data from a DataView.Thanks, Dave
I could really use some help on this.
I am intercepting grid_BeforeRowsDeleted and deleting the relationship just fine but after my event handler exits the row still shows because I have not figured out how to force the filter to again show the view which will now now show the row I deleted the relationship for. Some property like "reshow the view after the filter data changed" would be nice. Any suggestions??? Thanks, Dave
OK I found RefreshFilterRows and got this to work but would still appreciate some guidance on this whole topic.
Does row filtering happen as the band is reading through the dataset table and deciding to display each row? That seems as efficient as a DataView as long as the data is not copied and stored separate from what is actually shown in the view.
Thanks, Dave
Why no feedback on this? I'd still like any suggestions on best practice for this. Dave
Hi Dave,
The way you are doing it seems like a perfect approach and is exactly what I would have suggested.
Handle BeforeRowsDeleted, remove the relationship and cancel the event. Then you just need to refresh the grid in some way that the row no longer shows up, since the grid won't get a notification when you remove the relationship in your data.
I'm not sure why refreshing the grid filters would work for this. I would have recommend that you call grid.Rows.Refresh(ReloadData). But I'm not entirely sure that I understand what filtering you are doing or how you are doing it.
Thanks Mike. It's working out pretty well. If I'm at a subnode on my tree then I don't display all the table data but rather filter it qualified by the parent node in the tree. I have a FilterRow event that says whether to show the row. I need to refresh my filter criteria since it is based on the rows in a relationship table where I just deleted some data. I will look at my use of RefreshFilters and Refresh. I would supply virtual data for those rows except I want them to be part of the BIndingSource so I get child rows. Thanks for the ideas...
codeslinger said:I am under the impression that I must set the grid to a BindingSource and tablename so that I can drill down into child rows. Do you still see child bands if setting a grid to a datatable or if want filtered, to a dataview rather always using a BindingSource and table name? If so, what is the benefit of using the BindingSource?
A DataTable has no information about hierarchical data. It can't display child bands. But you could use a DataSet with multiple tables.
I'm not absolutely sure of the advantages of using a BindingSource, to be perfectly frank. That's more of a question for someone at Microsoft or maybe a general DotNet programming forum. One thing I can tell you is that there are some performance issues that occur when not using a BindingSource sometimes.
Hi Mike, Yes, I just update my filter data which changes since I removed one or more relationships.
What would be nice is if I could get rid of my filtering since I am a bit concerned if I have a large table to filter.
I am under the impression that I must set the grid to a BindingSource and tablename so that I can drill down into child rows. Do you still see child bands if setting a grid to a datatable or if want filtered, to a dataview rather always using a BindingSource and table name? If so, what is the benefit of using the BindingSource?
Okay, I'm still not entirely clear on why refreshing the filters has anything to do with removing rows from the data source. But if you are just changing the data that needs to be filtered rather than actually removing anything, then RefreshFilters sounds like the right way to go.
Mike, I tried both of the following after I reloaded my filter criteria from my data node and RefreshFilters shows the new grid with any deleted row relationships that were removed from my filter criteria and Refresh w/ Reload did not work as the grid_FilterRow event was not called when the data was supposedly reloaded. Is that normal? I would guess if reloading the data that the rows would have been filtered again. Would like you opinion on if that is normal or might be a bug. Thanks, Dave
mUltraGrid.DisplayLayout.RefreshFilters();
and
mUltraGrid.Rows.Refresh(RefreshRow.ReloadData); // this does not work!