【发布时间】:2017-11-21 09:58:40
【问题描述】:
我正在拼命地尝试在我创建的 jqGrid 中显示我的数据库中的数据,但我真的不明白它是如何工作的。
我仔细阅读了有关 jqGrid 的文档并尝试调整官方网站的演示,但我找不到简单的方法来用 PHP/MySQL 或 AJAX 脚本替换网格的“数据”选项。这是我的代码:
<script>
$(function (){
$("#grid").jqGrid({
colNames: ["ID", "Context", "IP", "Community", "Modèle", "Uptime", "Version Soft", "Version Patch", "Date d'ajout", "Date modif", "Refresh"],
colModel: [
{name:'id', index:'id', width:60, sorttype:'int', align:'center'},
{name:'context', index:'context', width:130, align:'center'},
{name:'ip', index:'ip', width:150, align:'center'},
{name:'community', index:'community', width:100, align:'center'},
{name:'modele', index:'modele', width:80, align:'center'},
{name:'uptime', index:'uptime', width:150, align:'center'},
{name:'soft', index:'soft', width:150, align:'center'},
{name:'patch', index:'patch', width:150, align:'center'},
{name:'ajout', index:'ajout', width:100, sorttype:'date', align:'center'},
{name:'modif', index:'modif', width:100, sorttype:'date', align:'center'},
{name:'refresh', index:'refresh', width:70, align:'center', formatter:refresh_Button}
],
data: [
{id:"1",context:"LAB",ip:"192.168.xx.xx",community:"public",modele:"S57",ajout:"20-11-2017"}
],
caption: "Equipements disponibles :",
sortname: 'id',
sortorder:"desc",
rowNum:20,
rowList:[20,40,60],
pager:'#yolo'
});
function refresh_Button(cellvalue, options, rowobject){
return '<button type="button" onclick="">Go</button>';
}
});
</script>
</head>
<body>
<table id="grid"></table>
<div id="yolo"></div>
</body>
</html>
有谁知道如何做这样的事情?
【问题讨论】:
标签: javascript php ajax database jqgrid