Dynamic loading lead to error

Hi,

I’m trying to implement a grid using a datastore with paging enabled.

On the client side, it looks something like this

var grid_clients = cell_clients_list.attachGrid();
grid_clients.setIconsPath(dhtmlx.image_path);
grid_clients.setColumnIds(...);
grid_clients.setHeader( ... );
grid_clients.setColTypes(...);
grid_clients.setColumnMinWidth('60,*,*,*,*,*,*,*');
grid_clients.setColAlign('left,left,left,left,left,left,left,center');
grid_clients.enableResizing('true,true,true,true,true,true,true,true');
grid_clients.setColSorting('int,str,str,str,str,str,str,str');
grid_clients.setInitWidths("60,*,*,*,*,*,*,*");
grid_clients.attachFooter(["<div id='grid_clients_recinfoArea' style='width:100%;height:100%'></div>","#cspan","#cspan","#cspan","#cspan","#cspan","#cspan"],['height:25px;text-align:left;background:transparent;border-color:white;padding:0px;']);
grid_clients.init();
grid_clients.enablePaging(true, 25,  10, 'grid_clients_recinfoArea', true, 'grid_clients_recinfoArea');
grid_clients.setPagingSkin('bricks', skin);
var clientsDataStore = new dhtmlXDataStore( {url:'clients.php', dataFeed:'clients.php', datatype:'xml' } ); 
grid_clients.sync( clientsDataStore );            

On the server side, the connector looks like:

    $start = 0;
    if(isset($_GET["start"])) $start = intval($_GET["start"]);

    $count = 20;
    if(isset($_GET["count"])) $count = intval($_GET["count"]);
    
    $connector = new GridConnector($dbh->connection, "FrontBase"); 
    // I implemented a custom frontbase connector which uses the syntax top(x,y) instead of limit(count)

    if ($connector->is_select_mode()) //code for loading connector
    {
        $connector->set_encoding("ISO-8859-1");
        $connector->dynamic_loading($count); // top(x, y)
        
        //if this is the first query - get total number of records in the query result
        if ($start == 0)
        {
            $sql = "select count(*) from Client where $where";
            $totalCount = $dbh->getOne($sql);
        }     
        
        $sql = "select ... where ...";
        $connector->render_sql($sql, "id", "...");
    }

However, when I execute the code, the client.php file is called, with no paramters. The response contains the nb. of rows ( ) and the I get an error from the Grid object:

Any idea where I’m doing something wrong?

Hi, could you provide our including dhtmlx.js file?
If you’re using pro-version you may attach it in private message.

Using Chrome, I get some more details about the error:

so the variable “url” is set to true instead of a string. I assume. Now, I don’t know why.

It’s actually the dhtmlxGrid property “xmlFileUrl” that is set to “true” somehow and passed to the
It’s either the clear_url or combine_url call that fails since it expects a string in parameter but receives a boolean. This happens when trying to render the grid and building the string send to the connector php file (the one containing posStart etc.).

The event seems to be “onDynXLS”

Hope that helps

oops read: “passed to a function where it is set to the url variable”

Any news on this?

Hi,
I tried to replay tlour issue locally using dhtmlx.js which you sent me, but it works correctly.
Here is code which I use to implement datastore and grid-pading:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<link rel="STYLESHEET" type="text/css" href="./codebase/dhtmlxgrid.css">
	<link rel="STYLESHEET" type="text/css" href="./codebase/ext/dhtmlxgrid_pgn_bricks.css">
	<link rel="stylesheet" type="text/css" href="./codebase/skins/dhtmlxgrid_dhx_skyblue.css">
	<script  src="dhtmlx.js"></script>
	<title>Grid with Smart Rendering (static) linked to Datastore</title>
</head>
<body>
	<div id="gridbox" style="width:600px; height:270px; background-color:white;"></div>
<script>
	var grid_clients = new dhtmlXGridObject("gridbox");
	grid_clients.setSkin("dhx_skyblue");
	grid_clients.setHeader("Count,Name");
	grid_clients.setColumnIds("Package,Version")
	grid_clients.setColTypes('ro,ro');
	grid_clients.setColumnMinWidth('60,*,*,*,*,*,*,*');
	grid_clients.setColAlign('left,left,left,left,left,left,left,center');
	grid_clients.enableResizing('true,true,true,true,true,true,true,true');
	grid_clients.setColSorting('int,str,str,str,str,str,str,str');
	grid_clients.setInitWidths("60,*,*,*,*,*,*,*");
	grid_clients.attachFooter(["<div id='grid_clients_recinfoArea' style='width:100%;height:100%'></div>","#cspan","#cspan","#cspan","#cspan","#cspan","#cspan"],['height:25px;text-align:left;background:transparent;border-color:white;padding:0px;']);
	grid_clients.init();
	grid_clients.enablePaging(true, 25,  10, 'grid_clients_recinfoArea', true, 'grid_clients_recinfoArea');
	grid_clients.setPagingSkin('bricks', "dhx_skyblue");
	
	var clientsDataStore = new dhtmlXDataStore( {url:"../common/data/bigdata.php", dataFeed:'../common/data/bigdata.php', datatype:'xml' } ); 
	grid_clients.sync( clientsDataStore );            
	
</script>
</body>
</html>

Try to use it. If still doesn’t work could you provide complete demo?
docs.dhtmlx.com/doku.php?id=othe … leted_demo

I can’t send you my exact code since I’m using a custom connector for a FrontBase database, but I produced a small app which loads the output from my connector (hardcoded). It produces the same error. So at least, we’ll both know what’s going on.

It gives a url.replace error since the variable is a boolean instead of a string

Here it is.

Martin
dynamic_loading_error.zip (307 KB)

Hi,
it seems that loaded in daastore data has incorrect format, it’s correct for dhtmlxGrid, but not for datastore.
Here is XML format doc:
docs.dhtmlx.com/doku.php?id=dhtm … plates#xml

I was using the GridConnector because it seemed to be the only connector to support dynamic_loading.

When I use a plain DataConnector, the command

$connector->dynamic_loading($count);

doesnt’ seems to work.

When the render_sql function is called, there are no total_count variable header in the xml.

What should I use as a connector for rendering to support dynamic_loading witha DataStore, synced to a grid and a form bound to it?

Do I have to do a custom “render_sql” function?

Thanks

Problem confirmed ( DataStore connector doesn’t provide dyn. loading info )
As fast solution - use DataViewConnector class, which will provide data in the correct format and will provide info for dyn. loading as well.

Hi, thanks for the confirmation.

I tried using the DataViewConnector as suggested. However, although it does indeed provide the right format and sends the 1st data batch with the total_count parameter, subsequent calls seem to lead to the same “url.replace” method not found. It seems the url variable contains a boolean instead of the intended url to the connector.

I provided an example with my connector output.
dataviewconnector.zip (307 KB)

Try to use the updated datastore.js from the attached sample ( it uses you static data set, so the new data will not be shown, but it sends correct request to server side during paging )
qw8421374.ZIP (332 KB)

I tried the new DataStore.js.

It does post parameters, but it is start and not posStart. So I don’t know if it’s a problem or not, but the xml ouput when the connector is called with start and count parameters does not contain the pos information in the header.

EXAMPLE:

query

result

Thanks!

If I “hack” the connector php file and set the variable:

 $_GET["posStart"] = $_GET["start"];

It seems to be working.