I have a unique requirement:
My current jQuery grid works fine. Currently I have editing enabled (Features => updating). Anyhow, I have to disable editing of a specific column once added. So basically, if someone add's a record they should be able to enter "Col A, B, C, D". However if they edit, only Columns A, B, and D should be editable.
Changing the column properties for updating to Read-Only for the column also affects adding a new row. Is there any way around this?
Hi,
You can easily accomplish this in cell update mode by handling the igGridUpdating.editCellStarting event and check the ui.rowAdding parameter. Here is the code:
features: [{ name: "Updating", mode: "cell", editCellStarting: function (evt, ui) { if ((ui.rowAdding == false) && (ui.columnKey == "Name")) { return false; } } }]
features: [{
name: "Updating",
mode: "cell",
editCellStarting: function (evt, ui) {
if ((ui.rowAdding == false) && (ui.columnKey == "Name")) {
return false;
}
}]
For update mode row you should handle igGridUpdating.editRowStarted, check the ui.rowAdding and show/hide the column editor by using the igGridUpdating.editorForKey API.
Here is the code:
features: [ { name: "Updating", mode: "row", editRowStarted: function (evt, ui) { if (ui.rowAdding == false) { var editor = $("#grid1").igGridUpdating("editorForKey", "Name"); $(editor).igEditor("hide"); } else { var editor = $("#grid1").igGridUpdating("editorForKey", "Name"); $(editor).igEditor("show"); } } } ]
features: [
{
mode: "row",
editRowStarted: function (evt, ui) {
if (ui.rowAdding == false) {
var editor = $("#grid1").igGridUpdating("editorForKey", "Name");
$(editor).igEditor("hide");
else
$(editor).igEditor("show");
]
Hope this helps,
Martin Pavlov
Infragistics, Inc.
Hi Martin,
Thanks for the reply, I think this will work, but I'm updating some code that is constructing the grid and its various properties in MVC e.g.:
ColumnUpdatingSetting fnSettings = new ColumnUpdatingSetting();fnSettings.ColumnKey = "FirstName";fnSettings.EditorType = ColumnEditorType.Text;fnSettings.Required = true;
Of course when the page renders all this is rendered as javascript, I guess my question is, If we enabled the Updating feature via MVC/Razor can specific update functionality be altered after the grid has rendered. I don't think we can.
It seems like, if I want this conditional edit functionality I will have to move my grid / feature construction to javascript completely so I can gain control. I can't create a GridModel in MVC and then conditionally alter properties via Javascript correct?
Actually I think I can hook into the events, via iggridupdatingeditrowstarting, I will try this. Ignore my last post