Hi,
I have a grid binded to a datatable, with ViewStyleBand set to OutlookGroupBy. The datatable is updated by program instead of user edit. User is allowed to drag columns as groupby columns. If there is only one groupby column, the groupby rows remains its expanded state as previously when data is udpated to the datatable. However, when I drag another column as GroupBy column (added up to 2 groupby cols), all rows will be automatically collapsed whenever there is data update. Any idea? I'm using RereshSortPositiion instead of SortedColumns.RefreshSort.
I'm afraid that nothing else comes to mind off the top of my head, and it seems strange that it doesn't happen with your test data but does with your actual data. Are the types of the two different sources the same (but simply with different columns/properties)? You should probably submit a small sample to Developer Support so that they can look into it.
-Matt
Hi Matt,
I encountered a very strange scenario here. I created a test project with some dummy data to check out the grid behavior. Two columns are dragged up as GroupBy columns. The grid behaves as expected, i.e. the GroupByRows never auto collapsed, whether to add a new row or update data. However, when I replace the dummy data with actual data (data columns are all different), the groupby rows automatically collapsed. I also added the code you've provided to check whether there is a reset notification. Surprisingly, there are ItemAdded/Changed notifications, but NO reset notification! Is there anything else can cause the groupby rows auto collapse?? Thank you.
You can determine if the grid is receiving a Reset notification by hooking the ListChanged event of the associated BindingManager. If you are binding the grid to a DataTable, your code might look like the following:
this.ultraGrid1.DataSource = dt;((CurrencyManager)this.BindingContext[dt]).ListChanged += new ListChangedEventHandler(Form1_ListChanged);
void Form1_ListChanged(object sender, ListChangedEventArgs e){ if (e.ListChangedType == ListChangedType.Reset) { }}
In my test, calling AcceptChanges on the DataTable sends a Reset notification, which could cause the grid to collapse the rows. As for the issue where simply adding a row causes them to collapse, this might be the same issue that I referred to in a previous post and might be addressed already, so you should contact Developer Support so that you can be notified when this fix is available. For what it's worth, adding a new row to the DataTable in my test with the latest code did not collapse any pre-existing GroupByRows, even when I was adding a row to an existing group.
I notice whenever Table.Rows.Add(DataRow) function, the GroupByRows are collapsed. Is there a way to avoid this?
Is there a way to know whether the grid has received a Reset Notification?
The DataTable has a primary key column (PK), and below is the code how it is updated. Will it cause the reset notification?
Thank you.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
DataRow [ drResults = tblData.Select(string.Format("PK='{0}'", inData.ID));
DataRow drTargetRow = null;if (drResult != null && drResults.Length > 0) drTargetRow = drResults[0];else{ drTargetRow = tblData.NewRow(); drTargetRow["PK"] = inData.ID; tblData.Rows.Add(drTargetRow);}
//update other columns if there is changesfor(int i=0; i < tblData.Columns.Count; i++){ string inItemValue = inData.GetData(tbleData.Columns[i].ColumnName; if (string.compare(drTargetRow[i].ToString(), inItemValue)) != 0) drTargetRow[i] = inItemValue;}tblData.AcceptChanges();
////////////////////////////////////////////////////////////////////////