smartRendering not working with server-side grid config

The client is not sending posStart and count as GET parameters to the server side php script.

I have this on the client:

<head>
	<title>DHTMLX Package</title> <link rel="stylesheet" type="text/css"  ref="codebase/dhtmlx.css">    <script src="codebase/dhtmlx.js"></script>
    <script>
        dhtmlx.image_path = 'codebase/imgs/';
        var mygrid;
        function doInitGrid() {
            mygrid = new dhtmlXGridObject('box');
            mygrid.setHeader("Prod name, Internal code, Price");

            mygrid.init();
            mygrid.enableSmartRendering(true);
            mygrid.load("data.php");   // works! client script sends posStart & count. 
            //mygrid.load("details.php");  // commenting above line and enabling this will load full data, and NOT send posStart, count.
        }
    </script></head>
<body onload="doInitGrid()">
    <div id="box" style="width:600px;height:650px;"></div>
</body>

data.php is test script copy-pasted from http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:step_3_loading_data_server_side_support_for_smart_rendering

details.php is my actual script that configures the grid on the server. Here are the relevant lines (somewhat edited):

$config = new GridConfiguration(true);
$config->setInitWidths("170,70,70,70,260");

$config->setHeader(array('col1', 'col2', ,'col3', 'col4', 'col5');
$config->setColSorting("str,str,str,str,str");

$grid = new GridConnector($res, 'Oracle');
$grid->enable_log($app_config['connector_log']);
$grid->set_config($config);
$grid->render_complex_sql($sql);
...

For the first call, grid will not provide posStart or count parameters - it will call url exactly as it was provided. Parameters will be added only to auto-generated calls.

If you want to have dyn. loading, add one line to the server side code

$grid->dynamic_loading(100); //enables dyn. loading $grid->render_complex_sql($sql);

Stanislav,

Thanks for your reply.

I added dynamic_loading call but it didn’t work with render_complex_sql.
In connecter log I see it appended
COUNT(*) as DHX_COUNT
to my rather complex query (that has 2 joins), and made the query sql invalid.
and then chrome said:

Uncaught TypeError: Cannot call method 'appendChild' of null dhtmlx.js:26140 dhtmlXGridObject._insertRowAt dhtmlx.js:26140 dhtmlXGridObject._insertRowAt dhtmlx.js:28939 dhtmlXGridObject._addRow dhtmlx.js:26094 dhtmlXGridObject.addRow dhtmlx.js:26099 dhtmlXGridObject.addRow dhtmlx.js:51237 (anonymous function) /simsmonitor/search/:109 xmlLoader.onloadAction dhtmlx.js:25543 check

It works with render_sql though, and I see the posStart and count being sent.
However, I remember reading in the docs that render_sql shouldn’t be used with complex queries. Is there anything particular to be concerned about?

Here’s the generated query that worked with render_sql:

[code]SELECT * FROM ( select /+ FIRST_ROWS(35)/dhx_table.*, ROWNUM rnum FROM (SELECT ‘dummy’ as subgrid,le.timestamp, le.tracker, le.log, USERAREA,SOURCE,FILENAME FROM event le
INNER JOIN
(SELECT max(timestamp) AS ts
FROM event
WHERE flowid=‘000815’
AND trunc(timestamp, ‘DDD’) > to_date(‘06-07-12’, ‘DD-MM-YY’)
GROUP BY tracker) maxdata
ON le.timestamp = maxdata.ts
LEFT JOIN
(SELECT
tracker
,MAX(CASE name WHEN ‘userArea’ THEN value ELSE NULL END) AS userArea
,MAX(CASE name WHEN ‘source’ THEN value ELSE NULL END) AS source
,MAX(CASE name WHEN ‘filename’ THEN value ELSE NULL END) AS filename

FROM
    app
GROUP BY tracker
) ac
ON le.tracker = ac.tracker
WHERE trunc(timestamp, 'DDD') > to_date('06-07-12', 'DD-MM-YY') ORDER BY le.timestamp DESC) dhx_table where ROWNUM <= 237 ) where rnum >202[/code]

Also, another question I have is, if it’s possible to show the progressOn animation while dynamic_loading is fetching data?

Thanks!!

As for progress - grid provides onXLS and onXLE event for start and end of data loading, you can assign any custom handlers to them, which can show message of init progress.

Normally render_complex_sql is a solution for the case when render_sql doesn’t work.
If render_sql generates data for plain loading - there is no any benefit in using render_comples_sql

In any case we will check functionality of render_complex_sql with dyn. loading and will fix it .

Stanislav,

Thanks very much for your replies!