//JavaScript deferred load in main.php
var lista = jQuery("#list").getDataIDs();
console.log(lista);
-------------------------------
//getdata.php
$responce = new stdClass;
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$responce->rows[$i]['id']=$row['slidescol'];
$responce->rows[$i]['cell']=array($row['torder'],$row['title'],$row['iconpath'],$row['bannerurl'],$row['summary'],$row['headerstitle'],$row['headers'],$row['backurl'],$row['forwardurl'],$row['thisurl'],$row['slidescol']);
$i++;
}
fclose($handle);
echo json_encode($responce);
我正在尝试确定为什么我的console.log
返回空白数组或空集,即使网格中有四行。
提前致谢...
答案 0 :(得分:1)
您提出的代码并未准确显示 JavaScript中您的代码将被称为方法getDataIDs
的位置。我想你把它叫做错误的地方。最初页面上的一个位置为空<table id="list"></table>
,那么您应该创建关于$("#list").jqGrid({/*options*/})
的网格。您只能在创建的网格上使用getDataIDs
,而不能在空<table>
元素上使用getDataIDs
。通常,在loadComplete
回调中使用{{1}},因为在该位置可以确保创建网格并且数据在jqGrid的主体中填充。
答案 1 :(得分:1)
对我有用的是什么:
...
loadComplete: function() {
var ids = $(this).jqGrid('getDataIDs');
// i'm expanding all the sub grids here, but can do anything with the array
var len = ids.length;
for (var i=0; i < len; i++) {
$(this).jqGrid('expandSubGridRow', ids[i]);
}
}