Touch Grid and datasource

Could someone give me a 10 liner example on how to get a touch ui grid to connect to a mySQL datasource. I’ve got the php that serves up the data (I use it for the standard non-touch grid and it works fine), I’ve tried every permutation,etc … to get it to work to no avail:

Please guys, I’ve spent all weekend on this and any help would be appriciated.

This is my code today…

The Front-end

/****************************************************************************************************************/

/*********************************** BACK END ******************************************************/

<?php $res=mysql_connect('localhost','root','***password***'); mysql_select_db('ipad'); require("./dhtmlx/codebase/treegrid_connector.php"); $grid= new GridConnector($res); $grid->dynamic_loading(100); $grid->render_table('addresses','id','name,email'); ?>

Hi,

Try to use JSONDataConnector:

<?php $res=mysql_connect('localhost','root','***password***'); mysql_select_db('ipad'); require("./dhtmlx/codebase/data_connector.php"); $grid= new JSONDataConnector($res); $grid->render_table('addresses','id','name,email'); ?>

In Grid initialization you need to define datasource:

dhx.ui({
id:“grid”, view:“grid”, header:true,
fields:[
{ id:“name”,label:“name”,},
{ id:“email”,label:“email”,}
],
url:“exAnaData.php”
})

You WONDERFUL person!

IT VERKZ !!

Does this also handle writing back the data to the database, or just filling the grid initially?
The great thing about the other method is that it handled large number of lines very elegantly with dynamic loading.

This was the full code stiched together from the online sample that starts here:

docs.dhtmlx.com/touch/doku.php?id=quick_start

but it doesn’t work!!!

***************************** BEGIN *****************************

Please have a look at the ready sample in Touch package:

dhtmlxTouch_10rc_110527/samples/technical/server/02_saving/03_list_dataprocessor.html

Thanks Again, Alexandra, but could I pls have a “fuller” url to that sample… the root is not very clear!

Sorry Alexandra, I always speak before I read! Obviously you mean the samples included in the download package… I’ll pull them apart and have a look!
Can I send you anything from Italy to thank you?

Thanks :slight_smile: There is no need to send gifts )
Hope you’ll enjoy our Touch library :wink:

Unfortunately it was a “virtual” gift, a thought, I can’t exacly send you 10lb of Parma Halm in the post can I?
I hope to enjoy the library enourmously, I’m just a bit confused about the language differences between your normal dhtmlx components and the touch ones, whether dynamic loading is supported or not, things like that …

Yep, I looked at your example and it all boils down to fixing the sqlLite code to mySQL:

<?php require_once("./../connector/data_connector.php"); /* if you want to use a different db type - include correct db_{some}.php - store opened connection in $db - set valid $dbtype name Check the next page for more details [docs.dhtmlx.com/doku.php?id=dhtm ... ide_others](http://docs.dhtmlx.com/doku.php?id=dhtmlxconnector:server_side_others) */ require_once("./../connector/db_sqlite.php"); if (!$db = sqlite_open('common/db', 0777, $sqliteerror)) { die($sqliteerror); } $dbtype = "SQLite"; ?>

/*****************************/

So I look at the suggested docs.dhtmlx.com/doku.php?id=dhtm … ide_others and it says that for MySQL I should put:

require(“connector/grid_connector.php”);
$res=mysql_connect(“localhost”,“root”,"");
mysql_select_db(“myDatabase”);
$gridConn = new GridConnector($res,“MySQL”);

which doesn’t really pair up with the sqlLite example!

So I look at the suggested docs.dhtmlx.com/doku.php?id=dhtm … ide_others and it says that for MySQL I should put:

GridConnector was just for example there. DataConnector will work with MySQL too. It is default db.

Thanks again Alexandra. A quicky: is dynamic loading supported (for huge tables) also i see no saving example for grid. Does it not work with touchUi?

Hi,

You can use loadNext method. Please have a look at the samples:

dhtmlxTouch_v10_111114/samples/technical/list/20_dyn_loading.html
dhtmlxTouch_v10_111114/samples/technical/list/21_page_loading.html