Hello dear developers.
I upload data from the server in this form....
	here @id and @p_id are unique keys for tree nodes and their parents.
For simple TreeGrid I use this code
	and it works great.
Now I decided to use the same thing in SelectItem and it doesn't work. I see an empty list for selection.
	I have to go through all the nodes in the tree and perform the following attribute assignments.  
And refuse a line of code
courseListProperties.setDataProperties(courseTree);
	How do I avoid this and make setDataProperties work?
Version v12.1p_2020-04-03
					I upload data from the server in this form....
Code:
	
	    "title": "Project DEMO",
    "node": "project",
    "@id": "6192",
    "@p_id": "0",
    "children": [
        {
            "title": "course template micro slides - L/R",
            "node": "course",
            "@id": "17519",
            "@p_id": "6192",
            "children": [
                {
                    "title": "1. Chapter Micro slides",
                    "node": "unit",
                    "@id": "17764",
                    "@p_id": "17519",
                    "children": [
For simple TreeGrid I use this code
Code:
	
	        Tree courseTree = new Tree();
        courseTree.setIdField(CONSTANT._ID);
        courseTree.setParentIdField(CONSTANT._PID);
        TreeGrid courseTreeGrid= new TreeGrid(object);
        courseTreeGrid.setKeepParentsOnFilter(true);
        courseTreeGrid.setDataProperties(courseTree);
Now I decided to use the same thing in SelectItem and it doesn't work. I see an empty list for selection.
Code:
	
	        ListGridField titleField = new ListGridField(CONSTANT.TITLE);
        JavaScriptObject object = JavaScriptObject.createObject();
        JSOHelper.setAttribute(object, "fireItemClickForFolders", true);
        Tree courseTree = new Tree();
        courseTree.setIdField(CONSTANT._ID);
        courseTree.setParentIdField(CONSTANT._PID);
        TreeGrid courseListProperties = new TreeGrid(object);
        courseListProperties.setKeepParentsOnFilter(true);
        courseListProperties.setDataProperties(courseTree);
        selectedCourse = new SelectItem();
        selectedCourse.setName("selectedCourse");
        selectedCourse.setWidth(300);
        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.setAutoOpenTree("all");
And refuse a line of code
courseListProperties.setDataProperties(courseTree);
Code:
	
	    private void setProjectNodesProperties(Record[] records, String chProperty, String dbName) {
        for (Record record : records) {
            String id = record.getAttribute(CONSTANT._ID);
            record.setAttribute("id", id);
            id = record.getAttribute(CONSTANT._PID);
            record.setAttribute("parentId", id);
            Record[] childs = record.getAttributeAsRecordArray(chProperty);
            if(childs != null && childs.length > 0) {
                setProjectNodesProperties(childs, chProperty, dbName);
            }
        }
    }
Version v12.1p_2020-04-03
Comment