about list's Dynamic Loading and php Connector question

my php Connector file:

<?php header('Access-Control-Allow-Origin:*'); require("./../dhtmlxconnector/data_connector.php"); $res=mysql_connect("localhost","root","root"); mysql_select_db("test"); mysql_set_charset("utf8"); $data = new JSONDataConnector($res,"MySQL"); $data->set_encoding("utf8"); $data->dynamic_loading(10); $data->render_sql("SELECT SEC_TO_TIME(a.cd) as cd, a.dz, b.mc AS dq, c.mc as msk FROM vvideo a INNER JOIN vdiqu b ON a.dq = b.dm INNER JOIN vmsk c ON a.msk = c.dm where a.zj='r'","dz","cd,dq,msk"); ?>
but list don’t display the data,the return json is:

{ "data":[ {"id":"131059","cd":"00:34:43","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"130382","cd":"00:28:29","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"286959","cd":"00:29:20","dq":"\u6b27\u7f8e","msk":"\u65e0\u7801"}, {"id":"410738","cd":"01:01:40","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"410820","cd":"01:04:04","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411333","cd":"01:16:48","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411249","cd":"01:31:35","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411979","cd":"00:51:10","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411844","cd":"01:55:04","dq":"\u65e5\u672c","msk":"\u6709\u7801"}, {"id":"411261","cd":"02:13:15","dq":"\u65e5\u672c","msk":"\u6709\u7801"} ], "pos":0, "total_count":273 }

and an ‘Unhandled Error: Cannot convert ‘a’ to object’ error at touchui.js line 4783

4781:zg: function() { 4782:this.g.select && this.data.each(function(a) { 4783:a.$selected && this.select(a.id) }, this) }, Hc: function(a, b, c) { if (!c && !this.callEvent("onBeforeSelect", [a, b])) return !1; this.data.item(a).$selected = b; c ? c.push(a) : (b ? this.o.push(a) : this.o.remove(a), this.yd(a)); return !0 },
I view the example in doc, the php file url ‘http://www.dhtmlx.com/touch/samples/04_list/books.php’ returns:

{ pos:0, data:[ { id:'x0', title:'Book 0', author:'Author'}, { id:'x1', title:'Book 1', author:'Author'}, { id:'x2', title:'Book 2', author:'Author'}, { id:'x3', title:'Book 3', author:'Author'}, { id:'x4', title:'Book 4', author:'Author'}, { id:'x5', title:'Book 5', author:'Author'}, { id:'x6', title:'Book 6', author:'Author'}, { id:'x7', title:'Book 7', author:'Author'}, { id:'x8', title:'Book 8', author:'Author'}, { id:'x9', title:'Book 9', author:'Author'}, { id:'x10', title:'Book 10', author:'Author'}, { id:'x11', title:'Book 11', author:'Author'}, { id:'x12', title:'Book 12', author:'Author'}, { id:'x13', title:'Book 13', author:'Author'}, { id:'x14', title:'Book 14', author:'Author'}, { id:'x15', title:'Book 15', author:'Author'}, { id:'x16', title:'Book 16', author:'Author'}, { id:'x17', title:'Book 17', author:'Author'}, { id:'x18', title:'Book 18', author:'Author'}, { id:'x19', title:'Book 19', author:'Author'}]}

there is no “total_count”,I delete the “total_count” and save to file, load the file to list ,it work well.
how to write the php file, can somebody give me a example like books.php?

Hello,

you are using connector correctly. The issue is caused by touchui.js. Please try to use libs attached to the following post:

viewtopic.php?f=22&t=28644&p=91174&hilit=dynamic_loading#p91340

They’ll fix the problem.

thanks,it works well now!By the way,I fix it like this:

dhx.ajax().get("vlist.php", {}, function(text, xml, xhr){ var objs = eval("(" + text + ")"); delete objs.total_count; $$('vlist').parse(JSON.stringify(objs),"json"); });

I download new libs,but in this code

var page = 0;
var pagecount = 1;
dhx.ready(function(){
	dhx.ui(config);
	dhx.ajax().get("list.php", {}, function(text, xml, xhr){
		var objs = eval("(" + text + ")");
		pagecount=Math.round(objs.total_count/20 + 0.5);
	});
	$$('tabbar').attachEvent('onaftertabclick', function(id,tab){
		if(tab =='prevpage'){prev();}
		if(tab =='nextpage'){next();}
	});
});
function next(){
	if (page<pagecount-1)
	{
		page++;
		$$('vlist').clearAll();
		$$('vlist').loadNext(20,page*20);
	}
}
function prev(){
	if (page>0)
	{
		page--;
		$$('vlist').clearAll();
		$$('vlist').loadNext(20,page*20);
	}
}

release the same error as above if not the first page,I found if ‘pos’ in json is not 0,it release the error,that’s a another bug?

pagecount=Math.round(objs.total_count/20 + 0.5);

Please check json that is generated by your “list.php”. connector includes total_count only if pos=0. And it is not a bug.

my list.php is copyed from vlist.php without any changes.
this time, when ‘pos’ in json is not zero,release the error!
the josn like this:

{ "data":[ {"id":"131059","cd":"00:34:43","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"130382","cd":"00:28:29","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"286959","cd":"00:29:20","dq":"\u6b27\u7f8e","msk":"\u65e0\u7801"}, {"id":"410738","cd":"01:01:40","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"410820","cd":"01:04:04","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411333","cd":"01:16:48","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411249","cd":"01:31:35","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411979","cd":"00:51:10","dq":"\u65e5\u672c","msk":"\u65e0\u7801"}, {"id":"411844","cd":"01:55:04","dq":"\u65e5\u672c","msk":"\u6709\u7801"}, {"id":"411261","cd":"02:13:15","dq":"\u65e5\u672c","msk":"\u6709\u7801"} ], "pos":20}

, when ‘pos’ in json is not zero,release the error!

As you can see there is not total_count property in json object that you provided. And in your code you are trying to get it:

pagecount=Math.round(objs.total_count/20 + 0.5);

total_count is generated only if pos is 0. You should consider this fact in your code. If you’ve found a bug in our library, please modify the demo from viewtopic.php?f=22&t=28644&p=91174&hilit=dynamic_loading#p91340 post and attach it.

you can visit the url:

http://feelsix.xp3.biz/mpv/test.html

the prev button release the error!

Dynamic loading that is built-in in connector can not be used with paging.

Please see the sample with paging in Touch package:
dhtmlxTouch_v12_120913/samples/04_list/15_page_loading.html

pos and total_count parameters are not included into the datasource