Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nicky F on Nov 13, 2007 04:41
open dhtmlx forum
Incorrect Xml on scrolling

Hi again,

I have successfully implemented a grid with loadXML from a jsp page (which outputs a xml string in the format of <rows><row><cell>). The data is loaded without any problems, but on scrolling down an error message is shown stating that there is an "Incorrect Xml" even though the data is shown. I'm using smartrendering ans setXMLAutoLoading for large datasets.

The following is the code i'm using for such:

mygrid = new dhtmlXGridObject('gridbox');
        mygrid.setImagePath("imgs/");
        mygrid.setHeader("Policy Number, Surname, Name, .. .. ..");
        mygrid.setInitWidths("85,90,90,95,90,100,110,80,80,145,0,0,0");
        mygrid.setColAlign("left,left,left,left,center,right,right,center,center,left,left,left,left");
        mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ed,ed,ro,ro,ro,ro");
        mygrid.setColSorting("str,str,str,str,str,str,str,str,str,str,str,str,str");
        mygrid.setOnEditCellHandler(doOnCellEdit);
        mygrid.setSkin("modern");
        mygrid.setXMLAutoLoading("dynload.jsp",30);
        mygrid.init();
        mygrid.enableRowsHover(true,"hover");
        mygrid.enableAlterCss("even","uneven");
        mygrid.enableSmartRendering("dynload.jsp",50);
mygrid.loadXML("xmlmanager.do");


dynload.jsp:

<%!
String accept = request.getHeader("accept");

if (accept.indexOf("application/xhtml+xml") >= 0){
     response.setContentType("application/xhtml+xml");
}else{
     response.setContentType("text/xml");
}

System.out.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");

int posStart = Integer.parse(request.getParameter('posStart'));
int count = Integer.parse(request.getParameter('count'));
%>
<rows pos="<%=posStart %>">

    <%!
        for (int i = 0; i < count; i++){
            
            System.out.println("<row id='r" + (i+posStart) + "'><cell>" + i + "</cell><cell>index is "+(i+posStart)+"</cell> " +
                      "<cell>load turn started from "+ posStart +" + " + count +"</cell></row>");
            
        }    
    %>

</rows>


Any information on ho to solve this issue would be great!

Thanks
Nick
Answer posted on Nov 13, 2007 05:38
I'm really not sure which result expected, when both auto-loading and smart rendering modes used.

Auto loading mode load data on demand ( while scrolling )

Smart-rendering can work in two modes
    - all data loaded at once and just parsed on demand
            mygrid.enableSmartRendering("dynload.jsp");
    - data loaded by demand while scrolling
            mygrid.enableSmartRendering("dynload.jsp".limit); //limit count of rows which expected, this is total count of rows in grid

So you need to use one mode at time, I suggest to use SmartRendering which provides better experience ( static modes for rows < 1000, dynamic mode for bigger datasets )