Hi, everyone,
Now I use a WinGrid to display data, the data is stored in a DataTable, and I register the
ultraDataSource1.CellDataRequested event, when this event is fired, I get data from the
DataTable, like below:
{if (e.Row.Band.Key == "RootBand" && e.Row.Index < _datatable.Rows.Count)
e.Data = _datatable.Rows[e.Row.Index][0];
break;}
}
now my question is: the user may make multiple changes from the UI(the WinGrid), and he/she wants to apply the changes
at one time, and there is a indicator to indicate that some changes have been made, but the user
has not applied it yet, anyone knows how to achieve this? Any help would be appreciated.
Thanks in advance.
Mike reminds me of that ALICE bot in that reply. :-P
Would the information at this link be helpful to you? It has information about getting the changed rows from a DataTable.
Hi, Mike and Torrey,
Thanks for your reply.
You know that I use the winGrid to display data, and the user can modify the data directly from the cells.
if the user edits the cells' data, there will be a indicator indicates that the data was changed, and I'd like to
use a button named "Apply changes", then if the users clicks this button, all changes were saved to the DataTable
or other DataSource.
Thank you very much!
Hi, Mike,
Thank you for your reply. please see 2 solutions below:
1. this.ultraGrid1.DataSource = dt; here dt is a DataTable, suppose there are 2 buttons, "Apply changes" and "Discard changes",
when the "Apply changes" button is clicked, I call "dt.AcceptChanges();",then the changes are saved to the dt; if I click
"Discard changes", I call "dt.RejectChanges();",then all the changes are discarded, and the ultraGrid displays its original data.
That works well.
2. Otherwise, if I set this.ultraGrid1.DataSource = this.ultraDataSource1, then use the "CellDataRequested" event to load data OnDemand from some other datasource, I set the UpdateMode
to Infragistics.Win.UltraWinGrid.UpdateMode.OnUpdate, and in the "ultraGrid1_BeforeRowUpdate" event, I set e.Cancel = true,
when I click the "Discard changes" button, I call "this.ultraGrid1.UpdateData()", then the "ultraGrid1_BeforeRowUpdate" event is fired
specified times according to how many rows were updated. but at last, I can only see the last row's data is reverted on the grid, not all
the rows, why? or I missed something?
Meanwhile, Are there some demos by using the "CellDataRequested" event, and show how to discard or save all changes?
I'm afraid you lost me.
Why are you setting the UpdateMode on OnUpdate? This setting actually does not work, because the BindingManager implicitly calls an update when it changes it's Current position.
And why are you cancelling BeforeRowUpdate?
And why are you calling UpdateData when the user clicks the Discard Changes button? That seems to be backwards.
A DataTable is specifically designer to be used with a database. So it has all kinds of functionality to deal with keeping track of which rows have changed so that it can cancel the changes or update the back end. UltraDataSource is designed to be a much simpler and fast data source and it has no such functionality. So if you want to be able to discard all changes made to all rows in the grid, you will have to implement some way to store the original values and do this yourself - the UltraDataSource cannot do this for you.
Thank you!
Now I know the UltraDataSource can't do it for me, so I revert a cell's value by reading its original value from
the latest saved datasource, and it works for me.
By the way, I encounter with a Exception when I set:
this.ultraGrid1.DisplayLayout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All;
this.ultraGrid1.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect;
to do cut/copy/paste, here is a column's type is double(Currency), and I set its format to "C" and so forth, for example,
at last, a number 1000000.69 will display as $1,000,000.69, if I copy this cell to another cell in the same column,
an error said "can't convert $1,000,000.69 to double". If I don't use this format, it works, but how can I do this with
using this format?
Thanks
That sounds like it might be a bug to me. You should Submit an incident to Infragistics Developer Support
Mike,
thank you, I have done that.
Was there a resolution to this