dhtmlxGrid: enableSmartRendering, posStart and count issue

When I add rows to a grid by calling either



taskTreeGrid.updateFromXML(url,true,true,calcFooterValues);

or

taskTreeGrid.load(url,calcFooterValues);



and the row “count” exceeds the default “count” variable in my JSP



String count = “”;

if (request.getParameter(“count”) != null) {

count = request.getParameter(“count”);

} else {

count = “50”;

}



dhtmlxGrid automatically adds “posStart” and “count” parameters to the URL (even when function ‘enableSmartRendering()’ is commented out)



and I get the following error messages:



FF 3.0.5 / Firebug 1.3.0



row is undefined

_get_cell_value()(undefined, 1, undefined)dhtmlxgrid.js (line 837)

collectValues()(1)dhtmlxgr…filter.js (line 73)

_loadSelectOptins()(select, 1)dhtmlxgr…filter.js (line 264)

refreshFilters()()dhtmlxgr…filter.js (line 299)

ev()()dhtmlxgrid.js (line 654)

ev()(“onXLE”, [Object entBox=div#taskTreeGrid_container.gridbox _wcorr=0, 0, 0, 1 more… 0=Object 1=0 2=0 3=XMLHttpRequest])dhtmlxgrid.js (line 654)

load()(Object entBox=div#taskTreeGrid_container.gridbox _wcorr=0, null, null, null, XMLHttpRequest)dhtmlxgrid.js (line 768)

waitLoadFunction()()dhtmlxcommon.js (line 15)

[Break on this error] _get_cell_value:function(row, ind, meth…, ind)method ? method : “getValue”},



IE6:



Line: 838

Char: 45

Error: ‘_locator’ is null or not an object

Code: 0





Any help is very much appreciated!

If you not using smart rendering or paging modes you need not to use the “total_count” property in XML.
When such property defined grid will be checking limits during any operation which may trigger auto-loading functionality.

>>When I add rows to a grid by calling either
grid.load can be used only to load initial set of rows, it can’t be used for adding new rows to existing dataset ( updateFromXML can be used for such task )

If smartRendering is disabled, it works fine now, thanks!

However, IE somethings breaks when I upload a lot of rows (> 100).
So enabling smartRendering would be a good idea.

How could I use it and prevent the errors from happening?

Also: I noticed that when “enableSmartRendering(true);” is set, the URL used to add more rows to the grid always sticks to the URL parameters initially set in “mygrid.load(initDataPath)”?

So how do I change parameters of “initDataPath” at runtime that are then being used when smart rendering steps in?

Thanks, Mort

So how do I change parameters of “initDataPath” at runtime
can be set as
grid.xmlFileUrl=“some new value”;

>>However, IE somethings breaks when I upload a lot of rows (> 100).
Please provide an example of problematic XML ( you can send it directly to support@dhtmlx.com )
The problem may be caused by non-unique IDs

Thanks for the hint, now however I run into another issue.

What I did was:

(1) uncomment “grid.enableSmartRendering(true);” so it gets rendered

(2) add “posStart”, “count” and “totalCount” calculation in my JSP file generating the XML (exactly as you showed in your sample implementation).
The only exception is that I set the default “count” value to 50:

String count = “”;
if (request.getParameter(“count”) != null) {
    count = request.getParameter(“count”);
} else {
    count = “50”;  
}

(3) add above values to tag:
out.println("<rows total_count="" + totalCount + “” pos="" + posStart + “”>");

(4) set “grid.xmlFileUrl = newUrl;” everytime I need to make changes to some values of the initial url

The result is that no matter how large the result set really is, I only get a max of 50 rows back.
So the issue definitely is related to setting "count = “50”.
However, setting it to “100” or so would not really solve the problem…

Thanks for your support!
Mort.

addition to my last comment:

In the URL that should return new rows when scrolling down (and triggering ‘smartRendering’),
both “posStart” and “count” are not included - only the parameters specified by me.

Also, the returned XML file shows the correct “totalCount” value, e.g.:




3632


//…

The grid however only renders 50 rows and does not “start” smart rendering when I scroll down.

In the grid’s attached footer, I have included the following code:

grid.attachFooter("Total rows: {#stat_count},#cspan,<div …

It always shows “50” as stat count (or less) but never the correct value (e.g. 683).

I have made sure that any “grid.clearAll()” is removed from the grid’s JS file.
When I update the grid, I always call

grid.updateFromXML(url,true,true,calcFooterValues);

Hope this helps to find a quick fix.

It always shows “50” as stat count (or less) but never the correct value (e.g. 683).
The stat_count show maximum expected number of rows , so if it sets to 50 then inner limit somehow was reduced to this value.

Such situation may occur when
a) incorrect total_count value returned from server
b) total_count value missed in xml response ( in such case grid doesn’t expect any extra rows )
c) you are using distributed parsing or paging in same time with smart rendering

According to above provided details , not one of reasons is actual in your case. If you have provided total_count for initial xml response - it can’t decrease on its own.

Latest version of dhtmlxgrid.js sent by email, it use slightly different code for updatFromXML functionality, please try to use it instead of original one.

I upgraded the dhtmlxgrid.js file but no effect.

I played around a bit with different ways of getting data from the server. If I use this code:

taskTreeGrid.xmlFileUrl = newUrl;  // set url for updating the grid to use current url
taskTreeGrid.clearAll();
taskTreeGrid.load(newUrl,calcFooterValues);

the following happens:

- the initial chunk of data contains correct value for “total_count” parameter in tag
- right after loading the first chunk, but before scrolling down [and triggering smart rendering]), the following error is thrown:

row is undefined
_get_cell_value()(undefined, 1, undefined)dhtmlxgrid.js (line 5465)
collectValues()(1)dhtmlxgr…filter.js (line 73)
_loadSelectOptins()(select, 1)dhtmlxgr…filter.js (line 264)
refreshFilters()()dhtmlxgr…filter.js (line 299)
z()()dhtmlxgrid.js (line 4611)
callEvent()(“onXLE”, [Object entBox=div#taskTreeGrid_container.gridbox _wcorr=0, 0, 0, 1 more… 0=Object 1=0 2=0 3=document])dhtmlxgrid.js (line 4591)
onloadAction()(Object entBox=div#taskTreeGrid_container.gridbox _wcorr=0, null, null, null, Document )dhtmlxgrid.js (line 5176)
waitLoadFunction()()dhtmlxcommon.js (line 15)
if (row._locator){

When I then scroll down, smart rendering is triggered and new data is correctly added to the grid:

- both “count” and “posStart” are added to the URL
(first time, posStart is “50”)
- the server’s response looks as follows:



3632

//…
If I scroll further down, “total_count” is always unset.
The ‘stat_count’ function always shows the initial value, up until I reach the “bottom” of the grid (e.g. have loaded all rows in the grid).
It then shows the correct value as specified in the initial chunk of data.

If I use “updateFromXML” instead of “load”:

taskTreeGrid.xmlFileUrl = newUrl;  // set url for updating the grid to current url
//taskTreeGrid.clearAll();
//taskTreeGrid.load(newUrl,calcFooterValues);
taskTreeGrid.updateFromXML(newUrl,true,true,calcFooterValues);

smart rendering does not work, no “count” or “posStart” parameters are added to any url and so no data is loaded when I scroll down.
Only the first 50 rows are added to the grid.
“total_count” value however is set correctly:




3632

//…

Any help is very much appreciated!!
Thanks for your great support,
Mort

the following happens:
According to error dump, you have #select_filter of #combo_filter attached to grid.
Both filters can be used only with static loading mode ( when all data loaded at once ) so they fail to collect list of possible options and throw mentioned error.
The error breaks functionality of filters but must not cause any side effects on further data loading.

>>The ‘stat_count’ function always shows the initial value, up until I reach the "bottom"
It uses onXLE event for updates, and while you have error with #select_filter it may be broken as well ( above error will stop code before stat counter updated )


>>taskTreeGrid.updateFromXML(newUrl,true,true,calcFooterValues);
here may be located the problem, please try to use it as
taskTreeGrid.updateFromXML(newUrl,true,false,calcFooterValues);

when you are using it with TRUE , grid will delete any row which not in incoming XML, so if you have only 50 rows in response of updateFromXML and parameter set to true - grid will delete all other rows in grid including other not loaded rows

When I set the third parameter of updateFromXML() function to false, I get a behaviour I don’t want to have…
In my scenario, users can use your calendar widget to pick a new date that requires the grid to get rid of all current rows and upload new rows.
So I have to stick to:

taskTreeGrid.updateFromXML(url,true,true);

However, smart rendering still does not work.

When I remove all #select_filters from the grid and use the following code to update the grid:

taskTreeGrid.clearAll();
taskTreeGrid.load(url);

then no error message appears anymore and smart rendering works fine!
“stat_count” does not cause any errors as well.

> Both filters can be used only with static loading mode ( when all data
loaded at once ) so they fail to collect list of possible options and
throw mentioned error.

What about “groups”? Do you also know about issues with “groupBy()” and smart rendering?
Obviously, as long as not all data has been downloaded to the browser, it cannot work properly.
However, I sometimes experience render errors when trying to group big sets of rows (> 300 rows).
So a general answer would suit me well…

Thanks,
Mort.

taskTreeGrid.updateFromXML(url,true,true);
In such case you will lost all not loaded yet rows, because the command state - load XML and delete ALL rows which not mentioned in it.

>>Do you also know about issues with “groupBy()” and smart rendering?
Same as filters, they can’t be used with dyn. loading mode - because to group data correctly - all info need to be available.
In current version of grid - the grouping not works fully correct with static smart rendering as well - only plain mode can be used with grouping.

If you need a big dataset to be shown in grouped state - you can use treegrid in srnd mode. ( it can’t use group api, but can represent any hierarchical data )