Hi!
I have a small issue with my ultragrid. It commits a newly added or modified row to the binded datasource just when the focus leaves the row. I don't like that, so i'm asking : is there a way to force the binding back to datasource at any time ? (when i click my "Save" button)
Thanks!
You can change the UpdateMode to OnCellChangeOrLostFocus.
BTW, I think you don't need to do it for the save button, because your grid loses focus and the default value is OnRowChangeOrLostFocus.
Hello,
Upon clicking a button the grid will lose focus and the row would be committed at that point unless the button is on a toolbar or menu. Since toolbars and menus don't take focus from the grid would not commit the row even though you have clicked your save button. If your save button is on a toolbar, you can use the following to commit the row:
this.ultraGrid1.PerformAction(UltraGridAction.CommitRow);
Let me know if you have any questions with this matter.
Alan
Thanks Alan!
Worked like a charm !
Thanks Amir also, for it's answer.
Is there a same way to commit the content of a cell without leaving it?
I've tried the ways described by Amir, but i don't know why, it didn't worked...
You can use the PerformAction method with the ExitEditMode value. The user will stay in the cell, the cell will be highlighted but not editable until clicked again.
Hi Gary,
The user's common sense has nothing to do with it.
The grid commits the changes to a cell when the user leaves the cell. It has to do it this way because otherwise, it would blow up on every keystroke. For example, say you have a DateTime field in your grid. The data source field presumably only accept valid DateTime values. So if the user enters the cell and deletes the existing text and the grid tried to update the data source with a null, it would fail.
That's actually not true, most data sources can handle null, even though the DateTime data type does not. But when the user started typing in a date, it would blow up on every keystroke that couldn't be converted into a valid date. If you were type "12/12/2001", it would blow up when you typed the first "1" and then again when you typed the "2", etc.
Even if "1" could be converted into a DateTime, this would be horribly inefficient and wasteful to update the data source on each keystroke. What if the data source had triggers on it that calculated other columns based on that change? It would be wasting processing power on calculations that were completely unnecessary.
So, the grid makes no attempt to update the data source until the user is finished editing, and the only trigger point for that is when the user leaves the cell.
If the user tabs or clicks on another cell, no problem. The grid know what the previous cell is deactivated and a new cell is activated and so it updates the data source.
If you click on some other control on the form, the grid loses focus and once again, the cell is updated.
But... toolbars don't get focus. They cannot, because if they did, it would be impossible to implement something like Cut, Copy, and Paste. If the toolbar took focus when you clicked on a Copy button, then how would your code know which control to copy from?
So... to answer your question, when you click a toolbar button, what you should do is call grid.PerformAction(ExitEditMode) to force the active cell out of edit mode. Then call grid.Update to commit any pending changes. In fact, I think the Update method might implicitly exit edit mode for you, so you might not need to call PerformAction yourself. But I might be wrong.
I am amazed that you seem so unaware of such a common issue and why once again infragistics fails to work as it should.
The issue is quite simple ok and should be common sense.
I am editing cells in win grid. Until I leave the row it is not commitet or changed. The USER!!!!!! doesn't care about this. He/she just clicks save on the toolbar and what should be commons sense is the row is commited and changed rows works correctly. However it does not. If I I get a dataview of this with only changed rows which is what a programmer would want!!!! I do not get that row. If I click on another row then it will work. Why would an average user think he / she has to click on another row?????
Gary
So the question is is there a way to fprce a commit.
Can you provide more details about what you mean by "without leaving it" (the cell)? Should the cell still be in edit mode or just still be active?
Also what are you looking to commit the cell in response to? What user action will trigger this?