Hi J,
Doesn't PerformAction return a boolean which indicates if the action was successful? If so, you could just skip the rest of the code if the PerformAction fails.
If I am wrong and there is no such return value, then you could check to see if the grid is still in edit mode after you call PerformAction. If so, you know the PerformAction failed and again, you can skip the rest of the code.
Hi Jamal,
How you are providing the button? Are you using the Style property of the column? Are you using Button or EditButton Style? Is the button in the same cell that is generating the error or in a different column?
I tried this out in a number of different ways, but I cannot get the button click to cause the grid to display an error. The only time this happens is when I try to leave the row.
Mike,
The Name column does not allow nulls (in ugClinicalGroups_InitializeLayout: col.Nullable = Infragistics.Win.UltraWinGrid.Nullable.Disallow;), and the Delete column is the one with the button.
Here is some code:
In Initialize (_dtClinicalGroups is a DataTable)...
_dtClinicalGroups = _daoClinicalGroups.GetAllClinicalGroups(); ugClinicalGroups.DataSource = _dtClinicalGroups;ugClinicalGroups.UpdateMode = UpdateMode.OnUpdate;ugClinicalGroups.ActiveRow = null;ugClinicalGroups.Selected.Rows.Clear();
ColumnsCollection cols = e.Layout.Bands[0].Columns;
cols.Insert(cols.Count, "ASSIGN_USERS");
{
col.Header.Caption = "Delete";
col.Width = 50;
break;
Also, I subscribe to BeforeCellActivate to make sure only certain cells are editable (I set e.Cancel = true if it's a non-editable cell). Is this the best way to insure that only certain cells are editable?
Let me know if I can provide any additional information.
Thanks,
J
Okay, I was able to reproduce the issue.
At a glance, it looks to me like the issue here is the Nullable property on the column. Since you are using the grid's column's Nullable property, the grid tries to validate the cell immediately when you try to leave it. The UpdateMode doesn't enter into it at all, because the grid is not committing the changes to the underlying data source at this point, it's just doing it's own built-in validation.
If, instead of using Nullable, your data source itself were set up to not allow nulls, then this validation would not occurr until you tried to update the row. So you might be able to work around this issue that way.
Oh... regarding disabling cells, there is an easier way. This KB article should help:
HOWTO:How can I make a grid or a column, row, or cell in the UltraWinGrid disabled or read-only?
Thanks again for your help. I have been working support issues, and am only now able to try this.
I've had the column from the datasource set AllowDBNull = false the whole time. When I took out the line set the ultragrid's column Nullable to Disallow, I get no validation from the datasource as the value of the empty cell is the empty string, not null or dbnull.
So I'm not able to skirt the issue that way. Looks like I'll have to manually validate the cell's value. Let me know if there's an easier way to do this.
Regarding disabling cells, setting CellActivation to Disabled greys out the columns. I don't want them greyed out, just not editable. So I set CellClickAction to RowSelect, and that seems to work.
Thanks again,
jammerms said:Regarding disabling cells, setting CellActivation to Disabled greys out the columns. I don't want them greyed out, just not editable. So I set CellClickAction to RowSelect, and that seems to work.
You could also use a setting of NoEdit or ActivateOnly, which would prevent editing and not change the cell color. Or, you could use Disabled and set the DisabledForeColor on the cell's appearance.