Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by udaya on Jun 05, 2008 03:49
open dhtmlx forum
SMART RENDERING

We are use Smart Rendering with dynamic loading and buffering..
a)Can you please tell,what is totalRows and Buffersize given for enableSmartRendering method?
b)What is the total_count attribute in the XML given for?What significance it has and what connection it has with the defined totalRows and BufferSize?
c)We have done with adding enableSmartRendering method from our JSP and writen the XML as follows

<?xml version="1.0" encoding="UTF-8"?>
<rows total_count="100" pos="1"><row id="1">
<cell>0</cell>
<cell>IC3</cell>
<cell>IXEDD</cell>
<cell>DECFF</cell>
<cell>2008</cell>
</row>
....


d)We have initialized the grid as follows,

mygrid = new dhtmlXGridObject('gridbox');
mygrid.imgURL = "images/";
mygrid.attachEvent("onCheckbox",doOnCheck);
mygrid.setHeader("a,b,c,d,e");
mygrid.setInitWidthsP("20,20,20,20,20")
mygrid.setColAlign("center,center,center,center,center")
mygrid.setColTypes("ch,ro,ro,ro,ro");
mygrid.setColSorting("str,int,str,str,int");    
mygrid.init();
mygrid.enableSmartRendering(true,5);
mygrid.loadXML(grid.xml);
Answer posted by Support on Jun 05, 2008 08:25
>>)Can you please tell,what is totalRows and Buffersize given for enableSmartRendering method?
Both parameters are optional and used only in case of dynamic smart rendering

buffere size - count of row which grid will request from server in one loading operation, equal to the height of grid by default
totat rows - expected amount of row in grid ( can be defined by rows@total_count attribute - which is recommended way )

>>b)What is the total_count attribute in the XML given for?
This attribute has the same purpose as totalRows parameter
You need not use it if all data loaded in one XML chunk.
It has sense for big datasets only - the 50000 sample loads only about 100 rows, but have the total_count attribute set to 50000, to inform component about expected count of rows.


>>c)We have done with adding enableSmartRendering method from our JSP and writen the XML as follows
a) If you no using dynamic loading total_count is options, if you are using dynamical loading - it must be equal to total count of rows which you expect to load in grid.
b) default value of pos attribute - 0

Answer posted by Support on Jun 05, 2008 08:26
Answer posted on Jun 05, 2008 08:45
We did the way i posted the initial code.we are using Struts framework where we dynamically write contents in a XML format and send it to the JSP where we have initialized the grid with smartRendering option enabled.

Iam trying to load 5 rows each time. I have set in the XML the totalRowCount as the value retrieved from the database irrespective of the number of rows to be displayed.This is set as 5.

The position for the first time is 0.So the first time loading is happening. When I scroll down the corresponding java script is also invoked. But from there the call dos not reach the Action class.Hence the loading for the next 5 rows is not happening.In JSP I given enableSmartRendering (true, 5).I suppose we are out of sync somewhere based on the values.We refered the step-by-step doc for smart rendering,but still coudnt figure out the reason.

Could you please guide us like how to proceed with the smart rendering like as of now only first 5 rows are geting loaded in the Grid and the rest are not loaded.

As o told we are giving the XML part as,

<?xml version="1.0" encoding="UTF-8"?>
<rows total_count="11" pos="0"><row id="1">
<cell>0</cell>
<cell>IC3</cell>
<cell>IXEDD</cell>
<cell>DECFF</cell>
<cell>2008</cell>
</row>
.......


d)We have initialized the grid as follows,

mygrid = new dhtmlXGridObject('gridbox');
mygrid.imgURL = "images/";
mygrid.attachEvent("onCheckbox",doOnCheck);
mygrid.setHeader("a,b,c,d,e");
mygrid.setInitWidthsP("20,20,20,20,20")
mygrid.setColAlign("center,center,center,center,center")
mygrid.setColTypes("ch,ro,ro,ro,ro");
mygrid.setColSorting("str,int,str,str,int");    
mygrid.init();
mygrid.enableSmartRendering(true,5);
mygrid.loadXML(grid.xml);

We are retrieving the data's from the database based on the number of rows we want.We have set this limit as 5.
Its still not working.Is there anything apart from this we have to do??

Answer posted by Support on Jun 05, 2008 09:11
The code which you are using for initialization is fully correct , same the XML.
The grid must render with scroll for 100 rows and render first 5 rows visible, after scrolling the next call to server side will occur. Component will call the same script as used in loadXML but with posStart and count parameters to show which data requested.

The attached sample uses the same code and XML, and it sends the second call for additional data with correct parameters.
Please try to use dhtmlxcommon_debug.js ( included in attached sample ) instead of default dhtmlxcommon.js - it show the url of request and response - please be sure that server side script sends back correct data ( with correct pos parameter )
Attachments (1)
Answer posted on Jun 05, 2008 23:09

Iam geting the smart rendering working when i dont set a limit for the number of rows to be fetched from the database.But the point is,i dont want the entire contents of the database to be loadeded in the XML.DB hold almost 200 rows of data's.Thats the reason iam seting a limit to fetch the number of rows.

My query is something like this - select a,b,c,d from sampledB and rownum<=5; (This will fetch only 5 rows each time)

My total_count is 5 in the XML and the the JSP holds - mygrid.enableSmartRendering(true,5);

 First time the 5 rows gets loaded.Next time when i click the scroll bar the call should reach the Action class from the JSP part(Struts Framework) and hit the DB and load the XML with the next 5 contents of the row.But this is not happening.

In the dhtmlxgrid_srnd.js file the "this.limit" value becomes 0 and hence the the further loading of data is not happening.

Please help me with this part.We just want to know how to load the XML dynamically with just 5 rows each time i click the scroll bar and not the entire content from the DB.

Answer posted on Jun 05, 2008 23:36

For you reference,

When we click the scroll bar to fetch the next 5 rows,in dhmtlcgrid_srnd.js,

the condition if ((!this.rowsCol[j])||(this.rowsCol[j]._rLoad)||(this.rowsCol[j]._sRow)) of askRealRows function FAILS..

So the call for loading the XML -   this.xmlLoader.loadXML(this._dload+((this._dload.indexOf("?")!=-1)?"&":"?")+"posStart="+start+"&count="+count+"&sn="+(new Date()).valueOf()); is not executed.

Why is this happening?

 

Answer posted on Jun 06, 2008 08:55
Hey its working when we comment the following line

if ((!this.rowsCol[j])||(this.rowsCol[j]._rLoad)||(this.rowsCol[j]._sRow)) of askRealRows function

Can you please tell me,how to make it work without doing this????
Answer posted by Support on Jun 09, 2008 05:33
The situation can occur in case of dhtmlxgrid 1.5 , when grid request data from server side, it sent a count of row expected to receive from server ( &count=NN ), if received count of row is lesser than  necessary , the situation occurs when row must be rendered but not info received from server - which may cause same situation as in your case.

To resolve problem you need to be sure that server side sends not lesser data than was requested by "count" parameter ( for initial loading it must be greater than count of visible rows in grid )
Also you can upgrade to dhtmlxgrid 1.6 , which has more simple buffering structure and not affected by incorrect server side responses.

The commenting of mentioned line in dhtmlxgrid_srnd.js , may resolve you problem , but, while not breaking main grid functionality, it may result in additional server side requests