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.
Hello - I am trying to get this to work for the cell editing, and I cannot get it to function. I have verified that the handler I assigned for event editCellStarting does get fired, and it does return false. I have used the debugger in Chrome to verify this. But it still allows the edit box to appear and be able to change the values in the grid. I am using Cell Edit model with MVC. Any thoughts on why the editing would still proceed?
In Controller (MVC)
GridUpdating updating = new GridUpdating();
//Add client event that gets fired after call updated ended. This will allow to enable the save button to function updating.ClientEvents.Add("editCellStarting", "HandleGridCellUpdatedStart(evt,ui);");
//Javascript
function HandleGridCellUpdatedStart(evt, ui) { //Purpoe: This gets called when Infragistics grid is starting to get updated
// alert('starting to update a cell');
if ((ui.rowAdding == false) && (ui.columnKey == "PartnerName")) {
//if not adding a row and the partner Name is trying to be updated, return right away return false; }
Update: I was able to get this to work but had a use a different approach as described in another post here. I am guessing adding a delegate is somehow different than attaching a client side event?
www.infragistics.com/.../iggrid---readonly-attributes-for-updating-a-record-non-readonly-attributes-for-adding-a-record