Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problems with XML datasources between different grids

    Greetings,

    We're using 7.0rc2. I have couple of list grids in a page and they are all bound to corresponding XML datasources. There are some JSP calls that return XML and they are being bound via xpath and this setup works fine for most part. At times the data gets jumbled up and it displays the data for list grid#2 in list grid #1.

    At first I thought this might be a synchronization problem, but now I don't think so. Am I missing something in the xml datasource? Is there any other technique to fix this issue? I tried startQueue() and sendQueue()
    for the fetchData() and draw() calls but they don't solve the problem.

    Somewhere in the docs I read that since XML based calls are not bound by RPC they don’t have any effect. In this case, how can we batch the calls and execute if we have to? Thanks.

    Below code snippet shows how they are defined and accessed:

    Code:
                isc.DataSource.create({
                            ID: "datasrc1",
                            showPrompt:false,
                            dataFormat:"xml",
                            dataURL:"/xxx/fetchData1.jsp",
                            recordXPath:"//DATA/ROW",
                            dropCacheOnUpdate:true,
                            preventHTTPCaching:true,
                    fields:[
                            {name:"data", valueXPath:"DATAPOINT", primaryKey:"true"},
                            {name:"y0" , valueXPath:"Y1", type:"text"},
                            {name:"y-1", valueXPath:"Y2", type:"text"},
                            {name:"y-2", valueXPath:"Y3", type:"text"}
                        ],
                    transformResponse : function (dsResponse) {
                                        <%-- Added this method to set the year values as title dynamically from XML --%>            
                var data = dsResponse.data;
                if(data){
                            try{
                        statCIKeyFinList.setFieldTitle(1, "<b>" + data[0].DATE_LABEL_CY + "</b>");
                        statCIKeyFinList.setFieldTitle(2, "<b>" + data[0].DATE_LABEL_PY + "</b>");
                        statCIKeyFinList.setFieldTitle(3, "<b>" + data[0].DATE_LABEL_PPY + "</b>");
                            }catch(err){
                        //Do nothing
                    }
                }
                }
                });
                isc.ListGrid.create({
                    ID: "listForDataSrc1",
                    alternateRecordStyles:true,
                    canReorderFields: false,
                    showAllRecords:true,
                    autoFetchData:false,
                    autoDraw:false,
                            canHover:true,
                            leaveScrollbarGap:false,
                    loadingDataMessage:"Loading xxxxx...",
                    width:"100%",
                    autoFitData:"vertical",
                    dataSource: datasrc1,
                    fields:[
                            {name:"data", title:"<b>Key Data Points</b>"},
                            {name:"y0"},
                            {name:"y-1"},
                            {name:"y-2"}
                        ]       
                });
                
    
                isc.DataSource.create({
                            ID: "dataSrc2",
                            showPrompt:false,
                            dataFormat:"xml",
                            preventHTTPCaching:true,
                            dataURL:"/xxx/fetchData2.jsp",
                            recordXPath:"//DATA/ROW",
                            fields:[
                                                    {name:"data", valueXPath:"DATAPOINT", type:"text", primaryKey:"true"},
                                                    {name:"y0",   valueXPath:"Y1", type:"text"}
                            ],
                            transformResponse : function (dsResponse) {
                                        <%-- Added this method to set the year values as title dynamically from XML --%>            
                                        var data = dsResponse.data;
                                        if(data){
                                                    try{
                                                                statCIFinSumList.setFieldTitle(1, "<b>" + data[0].DATE_LABEL_CY + "</b>");
                                                    }catch(err){
                                                                //Do nothing
                                                    }
                                        }
                            }                   
                });
                isc.ListGrid.create({
                            ID: "ListForDataSrc2",
                            alternateRecordStyles:true,
                            canReorderFields: false,
                            showAllRecords:true,
                            autoFetchData:false,
                            autoDraw:false,
                            canHover:true,
                            leaveScrollbarGap:false,
                            loadingDataMessage:"Loading xxxxx...",
                            width:"100%", 
                            autoFitData:"vertical",
                            dataSource: dataSrc2,
                            fields:[
                                                    {name:"data", title:"  ", width:350},
                                                    {name:"y0"}
                            ]                           
                });
                
                isc.SectionStack.create({
                            ID: "sectionStk1",
                            visibilityMode: "multiple",
                            width: 600, 
                            overflow:isc.Canvas.VISIBLE,
                            headerHeight:17,
                            autoDraw:false,
                            sections: [
                                        {title: "List1", expanded: true, items: [
                                                    ListForDataSrc1
                                        ]},
                                        {title: "List2", expanded: true, items: [
                                                    ListForDataSrc2
                                        ]}
                            ]
                });
                
                dataSrc1.fetchData();
                dataSrc2.fetchData();
                sectionStk1.draw();

    #2
    For batching (aka Queuing) use the SmartClient Server. There's no reason to generate XML from .jsps - that's just inferior (in speed, amount of code, functionality and many other aspects). See the QuickStart Guide for details.

    As far as mixed up responses, you probably having a threading issue in your server-side code, which can happen from eg using variables incorrectly in .jsps. This is yet another reason to use the recommended server architecture - it's much harder to write bad threading code when using best practices.

    Comment

    Working...
    X