Announcement

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

    Infinite loop on updating records in paged TreeGrid

    Hi there,
    Like you have described in this thread, to update a record in a treegrid you can use
    Code:
    var dsResponse = {data: [record1], operationType: "update"};
    datasource.updateCaches(dsResponse);
    This worked like supposed with one or two nodes without problems and even with nodes that are children from each other, but at some point there seems to be a issue when updating.

    Executing the example below, firefox does get stuck and in chrome the tab is crashing after a while.
    Therefore liek in the gif shown below you ahve to open "root-1" "root-1-1" and then click the button.

    This happens with the latest releases of Smartclient 10.1 and 11.0 (SmartClient_v110p_2016-05-31_Pro) Click image for larger version

Name:	Animation 47.gif
Views:	105
Size:	608.2 KB
ID:	238373


    Code for reproduction:
    Code:
    isc.VLayout.create({
        "ID" : "rootLayout_5",
        "width" : "100%",
        "height" : "100%",
        "autoDraw" : true,
        "hideUsingDisplayNone" : false,
        "leaveScrollbarGap" : false,
        "members" :
        [
            isc.Button.create({
                title: "rename some treenodes'",
                width: 200,
                click:function(){
                    var datasource = theTreeGrid.getData().dataSource;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-1-1");
                    var record1 = datasource.copyRecord(updatedRecord);
                    record1.randomField="blubber";
                    record1.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-1-2");
                    var record8 = datasource.copyRecord(updatedRecord);
                    record8.randomField="blubber";
                    record8.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-1-3");
                    var record9 = datasource.copyRecord(updatedRecord);
                    record9.randomField="blubber";
                    record9.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-1");
                    var record2 = datasource.copyRecord(updatedRecord);
                    record2.randomField="blubber";
                    record2.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1");
                    var record3 = datasource.copyRecord(updatedRecord);
                    record3.randomField="blubber";
                    record3.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-2");
                    var record4 = datasource.copyRecord(updatedRecord);
                    record4.randomField="blubber";
                    record4.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-3");
                    var record5 = datasource.copyRecord(updatedRecord);
                    record5.randomField="blubber";
                    record5.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-4");
                    var record6 = datasource.copyRecord(updatedRecord);
                    record6.randomField="blubber";
                    record6.id=2017;
    
                    updatedRecord = theTreeGrid.data.find("title", "root-1-5");
                    var record7 = datasource.copyRecord(updatedRecord);
                    record7.randomField="blubber";
                    record7.id=2017;
    
                    var dsResponse = {data: [record1, record2, record3,record4, record5, record6, record7,record8,record9], operationType: "update"};
                    datasource.updateCaches(dsResponse);
                }}
            ),
            isc.TreeGrid.create({
                "ID" : "theTreeGrid",
                "width" : "100%",
                "height" : "300",
                "selectionType" : "multiple",
                "canEdit" : false,
                "showFilterEditor" : false,
                dataSource : isc.DataSource.create({
                    "fields" :
                    [{
                            "name" : "treeGridGeneratedIndex",
                            "primaryKey" : true,
                            "hidden" : true,
                            "canView" : false
                        }, {
                            "name" : "nameField",
                            "title" : "Reason",
                            "type" : "text"
                        }, {
                            "name" : "parentId",
                            "rootValue" : "root",
                            "foreignKey" : "treeGridGeneratedIndex",
                            "hidden" : true
                        }
                    ],
                    "dataFormat" : "json",
                    "dataURL" : "http://www.devset.de/treegrid5.php",
                    "transformRequest" : requestTransformer,
                    "transformResponse" : responseTransformer,
                    "recordXPath" : "\/resultData",
                    useHttpProxy : false
                }),
                dataProperties : {
                    openProperty : "isOpen",
                    childrenProperty : "children",
                    canReturnOpenFolders: true,
                    progressiveLoading : false
                },
                "autoFetchData" : true,
                "dataPageSize" : 50,
                "dataFetchMode" : "paged",
                "selectionProperty" : "isSelected",
                "fields" :
                [{
                        "name" : "nameField",
                        "title" : "Reason",
                        "type" : "text",
                        "canEdit" : true,
                        "canSort" : true
                    },{
                        "name" : "id",
                        "title" : "id",
                        "type" : "number",
                        "canEdit" : true,
                        "canSort" : true
                    }, {
                        "name" : "lastField",
                        "title" : "Name",
                        "type" : "text",
                        "canEdit" : true,
                        "canSort" : true
                    }, {
                        "name" : "randomField",
                        "title" : "random",
                        "type" : "text",
                        "canEdit" : true,
                        "canSort" : true
                    }
                ],
                "selectionProperty" : "isSelected",
                "members" :
                []
            })
        ]
    });
    function requestTransformer(dataSourceRequest) {
        var operationType = {
            operationType : dataSourceRequest.operationType
        };
        if (dataSourceRequest.operationType == "fetch") {
            var params = {
                delay: 300,
                sortBy : dataSourceRequest.sortBy,
                start : dataSourceRequest.startRow,
                end : dataSourceRequest.endRow
            };
        }
        return isc.addProperties({}, operationType, dataSourceRequest.data, params);
    }
    function responseTransformer(dataSourceResponse, dataSourceRequest, jsonData) {
        if (dataSourceRequest.operationType == "fetch") {
            dataSourceResponse.totalRows = jsonData.totalRows;
            dataSourceResponse.endRow = jsonData.endRow;
            dataSourceResponse.startRow = jsonData.startRow;
        };
    }
    Best Regards
    Simon

    #2
    Sorry for reposting,

    adding "invalidateCache:" does prevent the infinite loop, but therefore 2 additional requests are send (in the gif there are 4, 2 get requests and 2 option requests).

    If there are new requests there is no difference to reloadChildren on the parent of the object anymore?

    Click image for larger version

Name:	Animation 48.gif
Views:	45
Size:	416.8 KB
ID:	238375

    Comment


      #3
      We've resolved the problem in SC 10.1p and newer. The fix should be in the nightly builds dated 2016-06-05 and beyond.

      Comment


        #4
        fix confirmed
        thanks

        Comment

        Working...
        X