We have a grid that we use to display custom fields for a support ticket. It is docked inside another form. The grid has the column "label" sortindicator set as ascending. it is the second column in the grid. When the save data routine on the parent form is called and performs a refresh of the data, the sortindicator seems to be lost and the grid is ordered by the "optionid", which is the first column of the grid. Optionid column is hidden. This appears to have started happening only since we upgraded to version 10.1. is there any issues with the grid in 10.1 that would cause this?
Mike,
Tested per your instructions and it is only loosing the sort. it's not a major issue right now, so as I have time i will try to get a sample and file a support incident on it. thanks.
Hi Bob,
There were, of course, lots of changes to the code from one version to the next. But I can't think of anything in particular that would have caused this particular area to change.
It would help to know if you are losing the entire layout or just the sorting. You could test this by resizing one of the grid columns and see if you lose the size of the column in addition to losing the sort indicator. If so, then you are probably losing the whole layout. If not, then you are just losing the sorting and that would be really odd.
Either way, if the behavior changed and it's breaking your existing code, then it's something we would really like to look into. So if you can provide a sample demonstrating the behavior, we would be happy to check it out.
Thanks Mike. I will play around with that and see what I can do. My question now is why did this only start happening when we upgraded to 10.1? Was there some underlying change that brings this out?
Bob
HI ,
I was unable to reproduce this issue.
I bound a grid, sorted it by clicking on the column header. Then via a button click, i refreshed the datasource. The grid was still sorted on the column I clicked.
Here is my refresh code
private void ultraButton1_Click(object sender, EventArgs e) { NwindDataSetTableAdapters.EmployeesTableAdapter emp = new WindowsFormsApplication102.NwindDataSetTableAdapters.EmployeesTableAdapter(); emp.ClearBeforeFill = true; emp.Fill(nds.Employees); ultraGrid1.DataMember = nds.Employees.TableName; ultraGrid1.DataSource = nds; ultraGrid1.DataBind();
}
How are you refreshing your grid?
Sincerely,
Matt
Developer Support Engineer
Hi,
btesch said:When the save data routine on the parent form is called and performs a refresh of the data
My guess is that you are not just losing the sort indicator, but rather you are losing the entire layout of the grid. If you are setting the grid's DataSource or doing something that causes the DataSource to send a Reset notification, then the grid has to throw away everything and re-build the data structure and the rows based on the new data source.
The best thing to do is avoid doing this. But if you must do it, then you should save the DisplayLayout of the grid into a MemoryStream and then re-load it after the refresh is complete.