Javascript Ext网格中的分页
嗨,我使用的是ExtJSVersion4.1.8,我想在我的extjs网格上添加分页 我一直在使用Javascript Ext网格中的分页,javascript,php,json,extjs,pagination,Javascript,Php,Json,Extjs,Pagination,嗨,我使用的是ExtJSVersion4.1.8,我想在我的extjs网格上添加分页 我一直在使用 Ext.create('Ext.data.Store', { model: 'List', proxy:{ type: 'ajax', api:{ read:'getJson.php', }, extraParams:{ PRKEY : selectedProjId
Ext.create('Ext.data.Store', {
model: 'List',
proxy:{
type: 'ajax',
api:{
read:'getJson.php',
},
extraParams:{
PRKEY : selectedProjId
},
},
reader:{
type: 'json',
root: 'data',
}
});
这很好,但是如果我在php文件中更改json格式,并将根类型更改为其他字符串,如“users”,我就看不到任何数据
下面是我在getJson.php中创建json的代码
//in a loop
$aNode = array(
"Name" => "My Name",
"ID" => "123");
array_push($nodeArr, $aNode);
//end of loop
$json = new Services_JSON;
echo $json->encode($nodeArr);
下面是我想要运行的php代码
//in a loop
$aNode = array(
"Name" => "My Name",
"ID" => "123");
array_push($nodeArr, $aNode);
//end of loop
$json = new Services_JSON;
$jsonResult = array(
'success' => "true",
'users' => $nodeArr
);
echo $json->encode($jsonResult );
这是新的商店代码
Ext.create('Ext.data.Store', {
model: 'List',
proxy:{
type: 'ajax',
api:{
read:'getJson.php',
},
extraParams:{
PRKEY :selectedProjId
},
},
reader:{
type: 'json',
root: 'users'
}
});
请提供帮助,以便我可以在我的应用商店的读卡器中添加totalProperty并执行分页。在成功旁边添加totalProperty的值,例如:
$total = get_total_number_of_records();
$jsonResult = array(
'success' => "true",
'total' => $total
'users' => $nodeArr
);
服务器端必须遵守发送的start
和limit
参数以及total
,并且只返回limit
从start
开始的记录数,而不是全部从数据库返回 啊,伙计们,我知道了。
我在代理块外使用“reader”。我改变了它,并将其添加到代理中,它起了作用
干杯!下面是它的工作原理
Ext.create('Ext.data.Store', {
model: 'List',
proxy:{
type: 'ajax',
api:{
read:'getJson.php',
},
extraParams:{
PRKEY :selectedProjId
},
reader:{
type: 'json',
root: 'users'
}
}
});
您是否将存储定义更改为
reader:{type:'json',root:'users}
?是的,这是正在工作的旧存储示例,我将粘贴新的wait@Fahrad存储中有root:“任务”
,并且您正在发送带有键“用户”
的数组,这就是为什么您没有data@szapio很抱歉,这是我的问题中的一个输入错误。我现在在代码中使用“用户”,这样的更改应该会起作用。你成功了吗?什么叫“不成功”?发生了什么事与你的期望相反?错误消息?