【发布时间】:2017-12-05 05:31:30
【问题描述】:
Webix 数据表
我从 php 脚本中读取它,但它只抓取第一个数据集。 php 脚本接受 &page= [当前页面] 和 &size= [记录数] 如果我将所有记录都提供给它,我只能让它分页。 (这行不通,因为那是大约 1 gig 大声笑。
以下是数据示例。 [我将其限制为 2 个结果]
{
"count": 84,
"count_filtered": 84,
"rows": [
{
"id": 1,
"accountName": "test",
"status": 2,
"notes": null,
"globalIframe": null,
"globalPostback": null,
"postBackDelayMS": 0,
"streetAddress1": null,
"streetAddress2": null,
"postalCode": null,
"city": null,
"countryCode": null,
"stateProvince": null,
"accountManager": 1,
"paymentCycle": 0,
"minimumPayment": 100,
"paymentType": 0,
"paymentDetails": null,
"created_at": "2017-12-02 19:03:41",
"updated_at": "2017-12-02 19:03:41"
},
{
"id": 2,
"accountName": "ta",
"status": 2,
"notes": null,
"globalIframe": null,
"globalPostback": null,
"postBackDelayMS": 0,
"streetAddress1": null,
"streetAddress2": null,
"postalCode": null,
"city": null,
"countryCode": null,
"stateProvince": null,
"accountManager": 1,
"paymentCycle": 0,
"minimumPayment": 100,
"paymentType": 0,
"paymentDetails": null,
"created_at": "2017-12-02 19:07:49",
"updated_at": "2017-12-02 19:07:49"
}
],
"listable": []
}
这是我用来将数据拉入 webix 数据表的 JS。
var datatable = webix.ui({
view:"datatable",
container:"dataTable",
datafetch:20,
datathrottle: 500,
loadahead:100,
autoheight:true,
autowidth:true,
yCount:10,
autoConfig:true,
columns:[
{ id:"accountName", header:"Affiliate Name", width:tableWidth}
],
on:{
onBeforeLoad:function(){
this.showOverlay("Loading...");
},
onAfterLoad:function(){
this.hideOverlay();
}
},
url:function(details){
return webix.ajax("/affiliates/data?1").then(function(data){
var js = data.json();
var new_js = [];
for (key in js['rows']){
new_js.push({
id:js['rows'][key].id,
accountName:js['rows'][key].accountName
});
};
return new_js;
})
},
navigation:"true",
pager:{
container:"dataPager",
size:10,
group:4
}
});
datatable.attachEvent("onDataRequest", function(start, count, callback){ //count
var view = this;
console.log("GETTING DATA");
webix.ajax().get("/affiliates/data?size=10&page="+start/10).then(function(data){
console.log(data);
this.parse(data.json());
var js = data.json();
var new_js = [];
for (key in js['rows']){
new_js.push({
id:js['rows'][key].id,
accountName:js['rows'][key].accountName
});
};
return new_js;
})
return false;
})
我花了大约一周的时间试图弄清楚这一点,所以要温柔。 提前致谢。
【问题讨论】:
标签: javascript jquery json datatable webix