我正在尝试将 php 脚本的输出加载到 jqgrid 中,但我可以看到没有数据的表。
<div id='Results'>
<div id= 'abcd' style="display:block";>
<?php include("simple.php");?>
</div>
<script type="text/javascript">
jQuery(function($) {
var data= $('#abcd').text();
var data1= data.replace(/\"/ig,'\"');
var data1= data1.replace(/[\“\”\″]/ig,'\"');
jQuery("#tableid").jqGrid({
dataType: "json",
data:data1,
colNames:['snp_id','chr','start_pos','end_pos','class','refbase','variantbase'],
colModel:[
{name:'snp_id',index:'snp_id', width:50},
{name:'chr',index:'chr', width:50},
{name:'start_pos',index:'start_pos', width:60},
{name:'end_pos',index:'end_pos', width:75},
{name:'class',index:'class', width:75, align:"right" },
{name:'refbase',index:'refbase', width:75},
{name:'variantbase',index:'variantbase', width:150}
],
pager: '#pager',
rowNum:100,
sortname: 'snp_id',
sortorder: "asc",
viewrecords: true,
gridview: true,
height: '100%',
width: '100%',
caption:"Title",
loadComplete: function(reload) {
jQuery("#myGridID").trigger("reloadGrid");
}
});
});
</script>
Simple.php 将 JSON 格式的数据检索到名为“abcd”的 div
{"total":1,"page":1,"records":5,"rows":[{"id":"CaSNP000002","cell":[{"snp_id":"CaSNP000002","chr":"Ca4","start_pos":"10077235","end_pos":"10077254","class":"D","refbase":"CTCTCTCTCTCTCTCTCTCT","variantbase":null}]},{"id":"CaSNP000003","cell":[{"snp_id":"CaSNP000003","chr":"Ca4","start_pos":"10077245","end_pos":"10077254","class":"D","refbase":"CTCTCTCTCT","variantbase":null}]},{"id":"CaSNP000004","cell":[{"snp_id":"CaSNP000004","chr":"Ca4","start_pos":"10077253","end_pos":"10077254","class":"D","refbase":"CT","variantbase":null}]},{"id":"CaSNP000005","cell":[{"snp_id":"CaSNP000005","chr":"Ca4","start_pos":"10077254","end_pos":"10077255","class":"I","refbase":"------ ","variantbase":"CTCTCT"}]},{"id":"CaSNP000006","cell":[{"snp_id":"CaSNP000006","chr":"Ca4","start_pos":"10077254","end_pos":"10077255","class":"I","refbase":"-------- ","variantbase":"CTCTCTCT"}]}]}