Announcement

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

    reloadChildren on large paged TreeGrid

    Hi there,
    I have a huge tree with many nodes. I have a existing hierarchy like this:


    If I want to to add a node to the existing node "root-1" I have to reload the children of the "root-1"-node.
    In the example there are about 200 nodes under the "root-1"-node. In our production environment there could me >1000 nodes in respect of the selected filters.

    When calling reloadChildren it seems, that the current implementation does a full load of all children of the node. I have initialized a paged tree so there should be no reason to get all chidren of the node. Because the totalRows have changed (when adding a new node) I thought i have to call the reloadChildren method, but when calling it does fire >50 requests at the same time to the datasource.

    In the example below I'm only calling reloadChildren without adding an additional node to the children of "root-1".
    Click image for larger version

Name:	Animation 44.gif
Views:	138
Size:	223.9 KB
ID:	237961

    Only 12 nodes can be displayed at one time, so the first datasoruce-request should return enough nodes to display all needed nodes.
    Is there a way to call reloadChildren without running into multiple datasource-requests for loading all children of "root-1"? Or maybe a way to fetch only the nodes, wich are needed for displaying?

    I've tested this against the latest release and also with a version vom november 2015 and the behaviour is the same.

    This is the 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: "reload children of node 'root-1'",
                width: 200,
                click:function(){
                    theTreeGrid.data.reloadChildren(theTreeGrid.data.findById("root-1"));
                }}
            ),
            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/treegrid2.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" : "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

    #2
    reloadChildren() *must* to drop all of the loaded children and all of their indirect children. We can't make any assumptions about what is safe to retain, or we would stop new data from being shown for nodes that are already loaded, which is the main reason for calling reloadChildren().

    If, instead, you're trying to add a single new node at root, or make any other incremental change to one level of nodes, you want updateCaches(), not reloadChildren().

    Comment

    Working...
    X