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.
Unfortunately, activation email could not send to your email. Please try again.

Expand group(s) from ListChanged event

Thread ID:

Created:

Updated:

Platform:

Replies:

20559 Oct 21,2004 01:25 AM Oct 21,2004 03:58 AM Windows Forms 3
loading
Tags: Grouping
Jason Southgate
Asked On October 21, 2004 01:25 AM

Hello, I''ve been struggling with creating an algorithm for the following problem for a few hours now, I hope you can help. It appears to be simple. I am listening to the ListChanged event of the DataView providing the data for my GridGrouping control linkMonitorGrid, and if the [Status] field has a certain condition (values 0 or 1), I want to expand the group in which that child resides. At first I thought about using the NewIndex property and passing this to my own method, CheckForPossibleGridExpands: private void OnLinkViewChanged ( object sender, ListChangedEventArgs e ) { // if it''s an addition or an update if ( e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemChanged ) { CheckForPossibleGridExpands( e.NewIndex ); } else if ( e.ListChangedType == ListChangedType.Reset ) { CheckForPossibleGridExpands(); } } private void CheckForPossibleGridExpands(int rowIndex) { int status = Convert.ToInt16(this.linkMonitorGridView.Table.Rows[rowIndex]["Status"]); // compare the new status with the one currently stored in the grid if ( status == 0 || status == 1 ) { // fetch the primary key MarketID string marketId = this.linkMonitorGridView.Table.Rows[rowIndex]["MarketID"]; Syncfusion.Grouping.Table table = this.linkMonitorGrid.TableModel.Table; Syncfusion.Grouping.ElementsInTableCollection elements = table.Elements; //table.FilteredRecords RecordFilterDescriptor rfd = new RecordFilterDescriptor("MarketID", new Syncfusion.Grouping.FilterCondition(FilterCompareOperator.Equals, marketId) ); RecordFilterDescriptorCollection rfdc = new RecordFilterDescriptorCollection(); rfdc.Add(rfd); // expand the grid group table.ExpandAllGroups(); } } and overloading this method with one which iterates through the linkMonitorGridView.Table.Rows when I recieve a ListChangedType.Reset, but i am not thinking that I should perhaps apply a filter to the this.linkMonitorGrid.TableModel.Table? Is that the right approach?? Also am I correct that linkMonitorGrid.TableModel.Table.ExpandAllGroups() will expand the group one I have located the record in the table, or do I need to be traversing some actual grid properties to correctly use ExpandAllGroups()??? Thanks in advance for your assistance. Jason Southgate.

Administrator [Syncfusion]
Replied On October 21, 2004 03:04 AM

Hi Jason, applying a filter is not a good approach. It will modify the collection of available records for the table (Table.FilteredRecords). But you can use the UnsortedRecords collection and look up a record based on its source index. See below. private void OnLinkViewChanged ( object sender, ListChangedEventArgs e ) { // if it''''s an addition or an update if ( e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemChanged ) { Record r = this.linkMonitorGrid.Table.UnsortedRecords[e.NewIndex]; // and then either r.ParentTable.ShowRecord(r, true); // or r.ParentGroup.IsExpanded = true; } else if ( e.ListChangedType == ListChangedType.Reset ) { this.linkMonitorGrid.Table.ExpandAllGroups(); } } FYI - In the next version there will also be a PrimaryKeySortedRecords collection that you can then also use to quickly look up a record based on a primary key, e.g. Record r = this.linkMonitorGrid.Table.PrimaryKeySortedRecords[primaryKeyValue]; Stefan

Jason Southgate
Replied On October 21, 2004 03:56 AM

Perfect Stefan, I did this, in the end and overloaded the method too to cover ListChangedType.Reset: private void OnLinkViewChanged ( object sender, ListChangedEventArgs e ) { // refresh the grid summaries this.linkMonitorGrid.Table.SummariesDirty = true; this.linkMonitorGrid.Refresh(); // if it''s an addition or an update if ( e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemChanged ) { CheckForPossibleGridExpands( e.NewIndex ); } else if ( e.ListChangedType == ListChangedType.Reset ) { CheckForPossibleGridExpands(); } } private void CheckForPossibleGridExpands( int rowIndex ) { int status = Convert.ToInt16( this.linkMonitorGridView.Table.Rows[rowIndex]["Status"] ); // compare the new status with the one currently stored in the grid if ( status == 0 || status == 1 ) { Record r = this.linkMonitorGrid.Table.UnsortedRecords[rowIndex]; // expand the grid group r.ParentGroup.IsExpanded = true; } } private void CheckForPossibleGridExpands() { for ( int i=0; i

Jason Southgate
Replied On October 21, 2004 03:58 AM

Sorry this was the overloaded method in the end: private void CheckForPossibleGridExpands() { for ( int i=0; i

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;