{name:'sex', index:'sex', width:'70', align:'center',editoptions:{value:’1:男;2:女’}},
這樣不能顯示
注意jqGrid放grid.locale-cn.js的後面。否則會報錯。
jQuery("#editgrid").jqGrid({
datatype: "local",
height: 450,
colNames:['編號','用戶名', '性別', '郵箱', 'QQ','手機號','出生日期'],
colModel:[
{name:'id',index:'id', width:200, sorttype:"int"},
{name:'userName',index:'userName', width:200},
{name:'gender',index:'gender', width:90},
{name:'email',index:'email', width:125,sorttype:"string"},
{name:'QQ',index:'QQ', width:100},
{name:'mobilePhone',index:'mobilePhone', width:120},
{name:'birthday',index:'birthday', width:100, sorttype:"date"}
],
sortname:'id',
sortorder:'asc',
viewrecords:true,
rowNum:10,
rowList:[10,20,30],
pager:"#gridPager",
caption: ""
}).navGrid('#gridPager',{edit:true,add:true,del:true});
var mydata = [
{id:"1",userName:"polaris",gender:"男",email:"[email protected]",QQ:"33334444",mobilePhone:"13223423424",birthday:"1985-10-01"},
{id:"2",userName:"李四",gender:"女",email:"[email protected]",QQ:"222222222",mobilePhone:"13223423",birthday:"1986-07-01"},
{id:"3",userName:"王五",gender:"男",email:"[email protected]",QQ:"99999999",mobilePhone:"1322342342",birthday:"1985-10-01"},
{id:"4",userName:"馬六",gender:"女",email:"[email protected]",QQ:"23333333",mobilePhone:"132234662",birthday:"1987-05-01"}
];
for(var i=0;i<=mydata.length;i++)
jQuery("#editgrid").jqGrid('addRowData',i+1,mydata[i]);