Webix DataTable
我让它从php脚本中读取数据,但它只抓取第一个数据集。php脚本接受&page=当前页面和&size=记录的数量我只能让它分页,如果我给它所有的记录。(这不会起作用,因为那大约是1G的笑声。
以下是数据的一个示例。我已将其限制为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;
})我花了大约一周的时间来解决这个问题,所以要温柔点。提前谢谢。
https://stackoverflow.com/questions/47646682
复制相似问题