Forum


22:29

23/01/2010

In my grid, I have a number of columns marked as editable.
However, I need to make some of the rows being returned in the JSON to be readonly.
How can this be done?
Is there anything I can add to the JSON for those rows?
Can I iterate over the rows and set a flag to prevent editing on all the columns in that row?
Any other options?
Thanks,
Glen
02:11

04/11/2009

02:17

23/01/2010

Here's what I've tried...
function BeforeCellEdit(rowid, cellname, value, iRow, iCol) {
var grid = $('#results');
window.status = rowid + '-' + cellname + '-' + value + '-' + iRow + '-' + iCol; // confirm the values being received
var readOnly = grid.getCell(rowid, 1); // hidden cell containing True or False for a read-only row
if (readOnly == 'True') {
grid.restoreCell(iRow, iCol);
return false;
//TODO: this is not preventing edit
}
}
What else should be done?
02:31

04/11/2009

The first thing you should try is changing (readOnly == 'True') to use true without qoutes.
Outside that how come you're not trying the method I linked?:
beforeEditCell: function (rowid,name,val,iRow,iCol){
if (rowid == 1){
jQuery("#jqg_"+id,"#results").attr('editable',false);}},
If your looking for cell level changes I suggest:
$("#results").removeClass('edit-cell').setCell(rowid,'columnname','','not-editable-cell');
02:53

23/01/2010

Thanks Tim.
(I posted my entry immediately after yours, and didn't see yours...)
This is what I have now, and it is working:
function GridComplete() {
var grid = $('#results');
var rowids = grid.getDataIDs();
var columnModels = grid.getGridParam().colModel;
// check each visible row
for (var i = 0; i < rowids.length; i++) {
var rowid = rowids[i];
var data = grid.getRowData(rowid);
if (data.AccessType == '0') { // view only
// check each column
for (var j = 0; j < columnModels.length; j++) {
var model = columnModels[j];
if (model.editable) {
grid.setCell(rowid, model.name, '', 'not-editable-cell', {editable: false});
}
}
}
}
}
Most Users Ever Online: 715
Currently Online:
83 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