We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling SelectRow(rownr) should select the correct row in the GridView on filtered or sorted views
The wrong row gets selected.
var grid = new GridView<MyClass>(); ..... var collection = new SelectableFilterCollection<MyClass>(grid, somelist) {}; grid.DataStore = collection; collection.Sort = coll.Sort = (e1, e2) => e1.Name.CompareTo(e2.Name); .... coll.SelectRow(5);
The problem seems to be in the Rebuild method, that gets viewToModel wrong. Can be fixed by adding 1 line, see below
protected override void Rebuild() { base.Rebuild(); if (base.HasFilterOrSort) { viewToModel = new Dictionary<T, int>(base.Count); for (int i = 0; i < base.Count; i++) { viewToModel.Add(this[i], i); } modelToView = new Dictionary<int, int>(base.Count); for (int j = 0; j < base.Items.Count; j++) { if (viewToModel.TryGetValue(base.Items[j], out var value)) { modelToView.Add(j, value); // --------> my proposed fix for viewToModel viewToModel[base.Items[j]] = j; } } } else { viewToModel = null; modelToView = null; } }
The text was updated successfully, but these errors were encountered:
Hey @desmetdirk, thanks for reporting the issue and finding the fix! Yes it is indeed not setting up the correct mapping there.
Sorry, something went wrong.
a773336
Successfully merging a pull request may close this issue.
Expected Behavior
Calling SelectRow(rownr) should select the correct row in the GridView on filtered or sorted views
Actual Behavior
The wrong row gets selected.
Steps to Reproduce the Problem
Code that Demonstrates the Problem
Proposed fix
The problem seems to be in the Rebuild method, that gets viewToModel wrong. Can be fixed by adding 1 line, see below
Specifications
The text was updated successfully, but these errors were encountered: