jqgrid change cell input to readonly after grid loaded
how can i change cell input to "readonly" after i loaded all grid's data?
I want only the loaded rows to have this cell as readonly , when i add new rows i don't want this cell to be readonly.
Thank's In Advance.
UPDATE:
this is my code:
$("#Grid1").jqGrid(
{
editurl: "clientArray",
datatype: 'xmlstring',
datastr: '<%=_xml_string %>' ,
colNames:['','cell1','cell2', 'cell3'],
colModel:[
{name:'cell1',index:'cell1', hidden: true},
{name:'cell2',index:'cell2', width:150, editable:true, edittype:'text',sorttype:"int" ,
editoptions:
{
maxlength:5,
dataInit: function (elem)
{
$(elem).numeric(false);
$(elem).blur(function(event_)
{
});
},
dataEvents:
[
{
type: 'keydown',
fn: function(e)
{
var key = e.charCode || e.keyCode;
if(key == 113)
{
}
}
}
开发者_如何转开发 ]
}
},
{name:'cell3',index:'cell3', width:150 , editable:true,sorttype:"text" ,
editoptions:
{
readonly: 'readonly' ,
dataInit: function (elem)
{
$(elem).attr("tabindex","-1");
}
}
}
],
height: '120px' ,
autowidth: true,
shrinkToFit: false,
beforeSelectRow: function(rowid, e)
{
if (required_field != rowid && required_field!="") return false;
else
{
if( $(this).getGridParam('selrow') == rowid)
return false;
else
return true;
}
},
onSelectRow: function(id)
{
save_row(lastSel);
get_grid().editRow(id,false,'','','','','','','');
jQuery ('#' + id + _cell2').focus();
lastSel=id;
},
loadComplete: function()
{
var grid = $("#Grid1");
var ids = grid.jqGrid('getDataIDs');
for (var i=0;i<ids.length;i++)
{
var id_=ids[i];alert(id_);
grid.jqGrid('setCell',id_,'cell2','','not-editable-cell');
}
}
});
If you use some editing mode to edit the grid you can set any time 'not-editable-cell' on the cell or 'not-editable-row' on the row to prevent the cell or the row be editable. See this answer for the code example.
精彩评论