jqgrid是怎样对数据库进行增删查改的
1个回答
展开全部
jQuery("#crud").jqGrid({
url:'server.php?q=2',
datatype:"json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55, editable:true, editoptions:{readonly:true}, sorttype:'int'},
{name:'invdate',index:'invdate', width:90, sorttype:'date', editable:true, editrules:{date:true},formatter:'date', datefmt:'d/m/Y'},
{name:'name',index:'name asc, invdate', width:100,editable:true},
{name:'弯唯amount',index:'amount', width:80, align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'tax',index:'tax', width:80, align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'total',index:'total', width:80,align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'note',index:'note', width:150, sortable:false,editable:true}
],
rowNum:10,
rowTotal: 50,
rowList:[10,20,30],
pager: '#pcrud',
sortname: 'id',
loadonce: true,
viewrecords: true,
sortorder:"desc",
editurl: 'server.php', // this is dummy existing url
caption:"CRUD on Local Data"
});
jQuery("#crud").jqGrid('navGrid','#pcrud',{});
其实就是利用jqGrid自带的增删改按钮对grid中的数据进行操作,不同的是,每次操作后台不做任何事情埋散培。
所以要将editurl设为一个不作任何事情的url——比如一个空doGet/doPost方法的servlet。
但是不能不设置或者掘兄设置一个不存在的url,否则jqGrid会报一个404的错误提示。
url:'server.php?q=2',
datatype:"json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55, editable:true, editoptions:{readonly:true}, sorttype:'int'},
{name:'invdate',index:'invdate', width:90, sorttype:'date', editable:true, editrules:{date:true},formatter:'date', datefmt:'d/m/Y'},
{name:'name',index:'name asc, invdate', width:100,editable:true},
{name:'弯唯amount',index:'amount', width:80, align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'tax',index:'tax', width:80, align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'total',index:'total', width:80,align:"right",editable:true,editrules:{number:true},sorttype:'number',formatter:'number'},
{name:'note',index:'note', width:150, sortable:false,editable:true}
],
rowNum:10,
rowTotal: 50,
rowList:[10,20,30],
pager: '#pcrud',
sortname: 'id',
loadonce: true,
viewrecords: true,
sortorder:"desc",
editurl: 'server.php', // this is dummy existing url
caption:"CRUD on Local Data"
});
jQuery("#crud").jqGrid('navGrid','#pcrud',{});
其实就是利用jqGrid自带的增删改按钮对grid中的数据进行操作,不同的是,每次操作后台不做任何事情埋散培。
所以要将editurl设为一个不作任何事情的url——比如一个空doGet/doPost方法的servlet。
但是不能不设置或者掘兄设置一个不存在的url,否则jqGrid会报一个404的错误提示。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询