Forum
15:42
11/02/2010
Hi
I'de like to have an option 'Addable' or 'Insertable' on the colModel.
Why? Imagine this scenario:
I want a grid on a table with all crud operations. My table can have multiple columns which I don't want to be edited, like eg: primary key(s), incremental id, .. . However, I want some of those uneditable columns to be insertable in the add form.
I tackled this by following workaround in the navgrid add dialog properties:
var extraAddable = jQuery("#GenericTableManager").jqGrid('getGridParam', 'colModel');
for (var i = extraAddable.length -1; i > 0 ; i--) {
if (extraAddable[i].addable) {
$('<tr id="tr_' + extraAddable[i].name + '" class="FormData">' +
'<td class="CaptionTD">' + extraAddable[i].name + '</td>' +
'<td class="DataTD">' +
'<input id="' + extraAddable[i].name + '" class="FormElement ui-widget-content ui-corner-all" type="text" name="'
+ extraAddable[i].name + '" role="textbox">' +
'</td>' +
'</tr>')
.insertAfter($('.tinfo'));
}
}
}
Works just fine, but would be nice if this was a default option.
Sorry about the edits: pasting code is one hardcore business.
14:20
11/02/2010
Didn't like the implementation.
This is better:
beforeInitData: function (formid) { // Add fields which are addable but not editable. jQgrid doesn't know a property 'Addable'.
colModelIterator(function(col) {
if (col.addable) {
grid.setColProp(col.name, { editable: true });
}
});
},
afterComplete: function (response, postdata, formid) {
// Remove editable option.
colModelIterator(function (col) {
if (col.addable) {
grid.setColProp(col.name, { editable: false });
}
});
}
function colModelIterator(callback) {
var colModel = grid.jqGrid('getGridParam', 'colModel');
for (var index in colModel) { callback(colModel[index]); }
}
Most Users Ever Online: 715
Currently Online:
50 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66