Hello,
after I refresh my grid (resetting datasource and putting the new oen), I want to preserve the row selection.
How can i find a particular row from the datasource and make it the activerow,
tx
Marc
Hi Marc,
If you are causing the data source to send a Reset notification, then all rows in the grid are destroyed and new ones are created for the new data.
To find a row, you will need to loop through the rows in the grid, there's no built-in search functionality in the grid. If you know the position of the row you want in the BindingManager, then you can use that index to find the row in the grid using something like this:
this.ultraGrid1.Rows.GetRowWithListIndex(index);
I have the same scenario here, is it not possible to use the ultragrid1.rows.all.find() function to return the row? since we're resetting the grid, we can capture the field value from the grid prior to the reset.
Theres always the old fallback of looping through each row in the grid, but the Find method seems to be what we're looking for here, isnt it?
Um, I don't think so. I could be wrong, but I am pretty sure that the All property is a property on Collection and it just returns an Object array. I wasn't aware that there was a Find method on an Array, but even if there is, I assume it finds some object that you specify. I don't see how it would be able to find an UltraGridRow with a cell that has a particular value. It knows nothing about the grid or cells.
Mike, marcjannes, fergal1982
I have this same requirement in my project.
The .Find() method is a new LINQ extension for collections. However, because the .All property doesn't know that the items inside the RowsCollection object (UltraGrid1.Rows) are UltraGridRow objects, what seems to be syntactically correct is something like this ...
// get the row from the grid which represents the column for which the filter was modified. UltraGridRow colRow = this.ActiveGrid.Rows.OfType<UltraGridRow>().ToList().Find(row => row.Cells[0].Text.Equals(valueListColumnFiltersChangedEventArgs.Column.Name, StringComparison.CurrentCultureIgnoreCase));
Nice, emz. The LINQ approach works like a charm.
Thanks!
Thanks Mike - that's a great method - not sure when it was added, but I had totally missed it.
grid.Rows.GetAllFilteredInNonGroupByRows
<<< The LINQ approach works like a charm. >>>
Only if the grid is not grouped.
As far as I could tell the LINQ approach only works if the grid isn't grouped. There doesn't appear to be a method to get a list of all the UltraGridRow objects in a single query that I could figure out, that would work for a grouped grid.
Any reason why Infragistics couldn't provide a list of all of the UltraGridRow objects corresponding to all the rows in the data source? We are all having to reinvent the wheel by writing code to iterate throught the collection to get this information which is a common requirement for all of us - it sure would be nice if this was a standard method or property of the grid.