Announcement

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

    SelectItem.fetchData not call DSCallback

    Hello dear developers
    I noticed that calling fetchData in SelectItem does not call DSCallback, although data is loaded from the server.

    Code:
            DynamicForm selectForm = new DynamicForm();
            selectForm.setWidth("100%");
    
            ListGridField titleField = new ListGridField(CONSTANT.TITLE);
    
            JavaScriptObject object = JavaScriptObject.createObject();
            JSOHelper.setAttribute(object, "fireItemClickForFolders", true);
    
            TreeGrid courseListProperties = new TreeGrid(object);
            courseListProperties.setKeepParentsOnFilter(true);
    
            selectedCourse = new SelectItem();
            selectedCourse.setName("selectedCourse");
            selectedCourse.setWidth(350);
            selectedCourse.setPickListWidth(400);
            selectedCourse.setHoverWidth(400);
            selectedCourse.setDataSetType("tree");
            selectedCourse.setPickListProperties(courseListProperties);
            selectedCourse.setShowTitle(false);
            selectedCourse.setValueField(CONSTANT._ID);
            selectedCourse.setDisplayField(CONSTANT.TITLE);
            selectedCourse.setPickListFields(titleField);
            selectedCourse.setMultiple(false);
            selectedCourse.setAllowEmptyValue(false);
            selectedCourse.setAddUnknownValues(false);
            selectedCourse.setAutoFetchData(false);
            selectedCourse.setOptionDataSource(projectTreeData);
            selectedCourse.setPickListCriteria(courseFilter);
            selectedCourse.setAutoOpenTree("all");
            selectedCourse.setEmptyDisplayValue(Server.getModuleString("emptyCourseItem"));
    
            selectForm.setItems(selectedCourse);
    
            addMembers(selectForm);
    
            selectedCourse.fetchData(new DSCallback() {
                @Override
                public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                    setProjectTreeNodes(dsResponse);
                    selectFirstCourse();
                };
            });
    What did I miss or do wrong?
    Last edited by Hirn; 17 Apr 2020, 11:03.

    #2
    We can't tell, because we don't have your DataSource. You could turn this into a runnable test case if you switched to a clientOnly DataSource, or used one of our sample DataSources. Then we could take a look.

    What were you going to do in the callback?

    Comment


      #3
      We're asking about your callback because, if setProjectTreeNodes() is going to attempt to manipulate the SelectItem's data, that's likely to be invalid.

      Finally, remember to always post which specific product you're using, and the full version, and always test any issue against the latest patched build *before* posting (see smartclient.com/builds).

      Comment


        #4
        I have prepared a working example where this problem appears

        In this example, you can also look at other problems that I have encountered.

        1. when you select an item in the course list, the ID field is displayed as the value, not the title field. although my code is
        Code:
        selectedCourse.setDisplayField(TITLE);
        2. I have already written about this problem here

        https://forums.smartclient.com/forum...dataproperties

        If I uncomment a line
        Code:
        // courseListProperties.setDataProperties(courseTree);
        the component shows an empty list of courses

        3. The most unpleasant mistake. When I created the components, the page took a very long time to load. In the debug mode I saw thousands of warnings of this type

        Code:
        TMR9:WARN:ResultTree:isc_ResultTree_1 (dataSource: p0001_Data, created by: undefined):Adding node to tree with id property set to:6192. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
        until the error appears
        Code:
        ISC_Core.js:310 Uncaught RangeError: Maximum call stack size exceeded
            at Object.isc_c_Tree_isANodeLocator [as isANodeLocator] (ISC_Core.js:1831)
            at _3.isc_Tree_isANodeLocator [as isANodeLocator] (ISC_Core.js:1476)
            at _3.isc_Tree_getName [as getName] (ISC_Core.js:1567)
            at _3.isc_Tree__preAdd [as $1205] (ISC_Core.js:1638)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree__preAdd [as $1205] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1621)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
            at _3.isc_ResultTree___add [as $137a] (ISC_DataBinding.js:1969)
            at _3.isc_Tree___addList [as $137b] (ISC_Core.js:1667)
            at _3.isc_Tree___add [as $137a] (ISC_Core.js:1629)
            at _3.isc_c_Class_invokeSuper [as invokeSuper] (ISC_Core.js:298)
        After a long search, I added a line

        Code:
        record.setAttribute("isFolder", false);
        into the function

        Code:
        private void setProjectNodesProperties(Record[] records) {
        and the problem was solved. But I don't think that's what you intended.

        Version v12.1p_2020-04-03 (2020-04-03)
        Attached Files
        Last edited by Hirn; 20 Apr 2020, 08:29.

        Comment


          #5
          From a first look, many of the nodes you are returning lack values for the PK field, which is invalid and would create lots of problems.

          As far as folderness, please read the docs for Tree.isFolder(). We provide multiple ways to control whether a node is a folder, one is to explicitly set a property, as you've done.

          If you need more help, please prepare your test case properly: use a clientOnly DataSource, not a series of JSON responses.

          Comment


            #6
            I don't have access to the SelectItem component tree.
            I have the clientOnly attribute set in the DataSource.

            projectTreeData.setAutoCacheAllData(true);
            projectTreeData.setCacheAllData(true);
            projectTreeData.setClientOnly(true);

            "If you need more help, please prepare your test case properly: use a clientOnly DataSource, not a series of JSON responses."


            I work with data downloaded from the server, and it doesn't help me to create data in the program code.
            So the JSON example I think fully reflects the problems I described above.
            Last edited by Hirn; 20 Apr 2020, 13:35.

            Comment


              #7
              The JSON data you provided was broken (missing PK values), as we have explained.

              If you fix that and you still have problems you would like us to look into, we need things set up as a clientOnly DataSource rather than separate JSON responses. clientOnly DataSources can be populated from JSON test files, it's fairly easy.

              Comment


                #8
                Originally posted by Isomorphic View Post
                The JSON data you provided was broken (missing PK values), as we have explained.
                I carefully rechecked my json files again and came to the conclusion that all nodes have PrimaryKey. And it is unique for all nodes.
                I thought that if you assign a field in the DataSource in this way,
                DataSourceTextField idField = new DataSourceTextField(CONSTANT._ID);
                idField.setPrimaryKey(true);
                idField.setRequired(true);

                there should be no problems with loading. And it turns out that you have some additional requirements for the structure of json files. I would very much like to read about these requirements.
                Last edited by Hirn; 21 Apr 2020, 10:44.

                Comment


                  #9
                  I in the first topic asked a question about calling fetchData in SelectItem does not call DSCallback, although the data is loaded from the server.

                  Were you able to track it? Or do you also need a clientOnly data source to do this?

                  Comment


                    #10
                    There's a second problem - your field names are invalid - they must be valid JS identifiers (per docs). This would likely mess up internal indexing in the Tree model, resulting in a crash like you reported, and once there has been a crash the callback won't fire.

                    If you correct this and still think there's a problem, we can take a look at a test case, once it's minimal and uses a clientOnly DataSource.

                    With no license, no support contract in place, and having already analyzed a test case and found it flawed, please do not expect us to set up some kind of servlet to emulate your JSON responses. That's why we're insisting on a self-contained test case with clientOnly DataSources.

                    Comment

                    Working...
                    X