Have an issue where the user want to add several rows in a sequence, without loosing focus on the built in add-row feature.
(Add a row --> Return focus to the first cell in the build in add row, add another row, and so on....)
Tried the following code, after a row has been added...
ultraGrid.ActiveCell = ultraGrid.Rows.TemplateAddRow.Cells[0];
ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
... the built in add-row get focused, BUT before I receive the built in Data Error "Unable to update the row: Column (the first column) does not allow nulls".
(Have a datatable as datasource)
Any idea of how to focus the built in Add-row, or is there a way to get rid of the bult in validation temporarily?
M Segerby
Hi,
The error message seems to indicate that you are trying to commit an row to the grid with some null values in it's cells and the data source does not allow that. When you click into the template add row and start to edit the row changes from a template add row to a regular add row. If you try to leave that row, the row must be committed to the data source at that time. If the data in the row is not valid (like when there's a null in a field that does not allow nulls), then the row cannot be committed. It sounds to me like you want to have multiple template add rows visible at the same time, but there is currently no support for that in the grid.
We have a similar situation, except that we are not getting the errors you describe. In our case, we create the template row, set several cell values programmatically, and then we want the template row to be converted to a regular add row immediately. The problem is that if the user initiates an add row, and then focus leaves the grid before the user physically edits any cell data, the grid just drops the template row. We would like for the template row to be committed even if the user did not make any changes. We even tried saving the row data in the database, but the grid still does not display the row until it's datasource is refreshed. Is there any way to accomplish this?
The TemplateAddRow becomes a regular AddRow when the user modifies the row. If you modify the row in code, this does not occur. This is done intentionally, so that you can programmatically provide default values in the TemplateAddRow and show them to the user without actually creating an extra row of data in your data source.
If you want to tell the grid to treat the row as a regular AddRow, you can set the AddRowModifiedByUser property on the rows collection to true.
grid.Rows.AddRowModifiedByUser = true;
Sorry for the late reply. But that worked for me. Thanks a lot.