Hy!
I'm using a UltraDataSource object in order to load a custom object list into a WinGrid. And I'm looking for the best way to update a single row without having to reload the entire grid.
The thing is that the load process takes a while, and every time a property of my entity is modified the entire reload makes the application a little a annoying.
Why I'm using a UltraDataSource? Because the object is an interface, so in order to get all the properties of that object (including the inherited ones) I have to use a UltraDataSource.
Thanks, Luciano.
Hi Luciano,
I'm afraid I'm not sure what you are asking. If you update the values in a row of the UltraDataSource, then the UltraDataSource sends a notification to the BindingManager which will notify the grid and update the row.
What exactly do you mean when you say it's updating the entire grid? There's no reason that should be happening unless it's something in your code explicitly doing it.
The thing is that I need to tell the grid that an entity was modified. Instead of reload the entire grid I want to update only the row that represent the modified entity.
By updating the entire grid I meen reloading the entire informacion from the database and setting it to the UltraDataSource.Datasource property. This process will take a while just for a simple entity change.
Updating sample:
public void RefreshClientAddress(int clientId, IAddress updatedAddress){ // GETTING THE CLIENT REFERENCE FROM THE DATASOURCE. IClient client = GetClientFromDataSource(clientId);
// REPLASING THE OLD ADDRESS REFERENCE WITH THE NEW ONE. client.Address = updateAddress;
// PLACE DATAGRID ROW UPDATE CODE HERE.}
As you can see, I update the address object reference, but the grid doesn't known that.
Thanks.
Hi,
Have you tried calling the Refresh method on the grid row?
If that doesn't help, then you will need to use grid.Rows.Refresh(ReloadData).
Nop, nothing happends. I tried both, row and grid refresh methods and nothing happends.
I changed the entity but the changes doesn't be reflected.
Is there any property or method that I have to call in the UltraDataSource?
Well, there are quite a few variables here. My guess is that you are loading the UltraDataSource on-demand and so when you change your entity, you need to tell the UltraDataSource to clear it's cached information so it picks up the new data. You would use the ResetCachedValues method for this.
I don't think the UltraDataSource is working on demand. Is there any way to tell the UltraDataSource to work this way?
And I'm talling you this because all the info is loaded even when the grid's property LoadStyle=LoadOnDemand.
I tried using 'ResetCachedValues' in the UltraDataSource and all the info of the grid is cleared but it's not reloaded.
I tried using 'ResetCachedValues' in the DataRow and all the info of the row is cleared but not reloaded.
In both cases I used 'Refresh(RefreshRow.ReloadData, true)' but nothing happends.
To be exact I also save business object with changed properties to datarow's Tag, because I use it further.
Hi, ldcampana.
I replace the cell value like:
row.SetCellValue("ColumnA", new_value)
or
row["ColumnA"] = new_value;
and it works - row in the grid is updated.
As far as I understood only this direct setting new_value to the data cell can update the corresponding data row. I encounter with this situation too( when setting new value to data row's Tag does not force the UltraDataSource to call CellDataRequested event and reload the row.
Alex.
Hi!
And, when you said "row["a"] = new_value" you mean "dataRow.tag = new_value"? Or you replace the cell value like row.SetCellValue("ColumnA", new_value)?
Thanks!
Well, like I said, there are just too many variables here for me to tell you what you need to do or why my suggestions are not working. Maybe the easiest thing to do at this point is for you to create a small sample project demonstrating the behavior you are getting and Submit an incident to Infragistics Developer Support so they can check it out.
Hi.
I do not know which means of updating one row is the most accurate but I do it head-on:
1. I store the business object for each data row in tag.
2. Then when it's necessary to update the corresponding row I find it by the appropriate key of object that is in tag. I do it via iterating thru all rows of the grid until find the necessary one.
3. Then update it like this:
row["a"] = new_value;