Is there any way, in cell editing, to change the edittype of a cell when it is being edited (if certain conditions are met)?
Supposse I have a colModel that has a field "Description", which by default is going to be treated as an input. When I click to edit in that cell, and input is going to appear with the current cell value. Now, if certain condition is met, I'd like that when the user clicks that cell to edit it, instead of an input a select appears.
I've tried using setColProp and changing both the edittype and the editoptions, but either I haven't done so in the right place (I did it in the beforeCellEdit event), or it doesn't work that way.
Thanks.
UPD:
I have tried to use the strategy you proposed, but my cell still shows an input after I invoke the setColProp
method:
var originalEditCell = $.fn.jqGrid.editCell;
$.jgrid.extend({
editCell: function (iRow, iCol, isStartEditing) {
if (iCol === 4 && classEditMode) {
$(this).jqGrid('setColProp', "ColName4", { edittype: "text" });
var cell = $(this).find('tr:eq(' + iRow + ')').find('td[aria-describedby="gridFix_Description"]');
cell.find('select').remove();
cell.append($('<input />').attr('id', iRow + '_Description')
.attr('name', 'Description')
.attr('role', 'textbox')
.width('98%')
.text(""));
}
return originalEditCell.call(this, iRow, iCol, isStartEditing);
}
});
The grid still generates a select. Any idea why?
Thanks
UPD2
Sorry, I had forgotten to include the correct variable for the colname in the setColProp method. I corrected that in the post to keep record of how I solved this issue if somebody else needs it.
Thanks.