I am currently loading grid using XML generated on server side.
[code]header(“Content-type: text/xml”);
echo(‘<?xml version="1.0" encoding="ISO-8859-1"?>’);
echo ‘’;
$sql = “SELECT * from $tblname”;
$res = mysql_query ($sql);
if($res){
while($row=mysql_fetch_array($res)){
echo ("<row id='".$row['id']."'>");
print("<cell><![CDATA[".$row['name']."]]></cell>");
print("<cell>img/desc.png^Description</cell>");
print("<cell>img/select.gif^</cell>");
print("</row>");
}
}
echo '</rows>';
mysql_close($conn);[/code]
However, i would really like to use dhtmlxconnector for Grid for configuring the Grid as well as for loading and saving data. I am able to send “id” and “name” columns, but NOT the images.
$gridconn->render_table("dbasetable","id","id,name");
How i can add columns which are NOT linked to the database table and send the images or text to the client-side.
Thanks.
Can be done through beforeRender handler
function format_data($action){
$action->set_value("image", "imgs/some.gif")
};
$gridconn->event->attach("beforeRender", "format_data");
$gridconn->render_table("dbasetable","id","id,name,0(image)");
Sorry … but this did not work for me. Got an Error that column 0 could not be found.
Tried different combinations xxx(image), (image), 0(blah) ect … but everytime it complains the column cannot be found. I also update to the new connector codebase you gave out today … but still same error. Any hints?
[Thu Apr 11 10:53:32.130146 2013] [:error] [pid 824:tid 980] [client 127.0.0.1:57794] PHP Fatal error: Uncaught exception ‘Exception’ with message ‘MySQL operation failed\nUnknown column ‘0’ in ‘field list’’ in C:\Program Files\EasyPHP-12.1\www\base\connector\db_common.php:991\nStack trace:\n#0 C:\Program Files\EasyPHP-12.1\www\dbase\connector\db_common.php(668): MySQLDBDataWrapper->query(‘SELECT `dbasetable_…’)\n#1 C:\Program Files\EasyPHP-12.1\www\base\connector\base_connector.php(531): DBDataWrapper->select(Object(DataRequestConfig))\n#2 C:\Program Files\EasyPHP-12.1\www\base\connector\base_connector.php(512): Connector->get_resource()\n#3 C:\Program Files\EasyPHP-12.1\www\base\connector\base_connector.php(409): Connector->render()\n#4 C:\Program Files\EasyPHP-12.1\www\base\php\app_grid_conn.php(29): Connector->render_table(‘dbasetable’, ‘id’, ‘id,name…’)\n#5 {main}\n thrown in C:\Program Files (x86)\EasyPHP-12.1\www\base\connector\db_common.php on line 991, referer: 127.0.0.1/19%20base/base/app.php
Please try to change the above code as
$gridconn->render_table("dbasetable","id","id,name,id(image)");
Double-checked it locally - works as expected.