Announcement

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

    Record components in TreeGrid not indented properly after reparenting

    Hi Isomorphic,

    I have modified the Drag Reparent showcase sample to add a record component to the tree field.

    Code:
        public void onModuleLoad() {
    
            Tree employeeTree = new Tree();
            employeeTree.setModelType(TreeModelType.PARENT);
            employeeTree.setRootValue(1);
            employeeTree.setNameProperty("Name");
            employeeTree.setIdField("EmployeeId");
            employeeTree.setParentIdField("ReportsTo");
            employeeTree.setOpenProperty("isOpen");
            employeeTree.setData(employeeData);
    
            TreeGridField formattedField = new TreeGridField("Name");
    
            TreeGrid employeeTreeGrid = new TreeGrid() {
                @Override
                protected Canvas createRecordComponent(ListGridRecord record, Integer colNum) {
                    String fieldName = this.getFieldName(colNum);
                    if ("Name".equals(fieldName)) {
                        String name = record.getAttribute("Name");
                        IButton button = new IButton();
                        button.setTitle(name);
                        button.addClickHandler(event -> SC.say(record.getAttributeAsString("Job")));
                        return button;
                    }
                    return null;
                };
            };
            employeeTreeGrid.setWidth(500);
            employeeTreeGrid.setHeight(400);
            employeeTreeGrid.setNodeIcon("icons/16/person.png");
            employeeTreeGrid.setFolderIcon("icons/16/person.png");
            employeeTreeGrid.setAutoFetchData(true);
            employeeTreeGrid.setCanReorderRecords(true);
            employeeTreeGrid.setCanAcceptDroppedRecords(true);
            employeeTreeGrid.setShowOpenIcons(false);
            employeeTreeGrid.setDropIconSuffix("into");
            employeeTreeGrid.setClosedIconSuffix("");
            employeeTreeGrid.setData(employeeTree);
            employeeTreeGrid.setFields(formattedField);
            employeeTreeGrid.setShowSelectedIcons(true);
            employeeTreeGrid.setShowRecordComponents(true);
            employeeTreeGrid.setShowRecordComponentsByCell(Boolean.TRUE);
            employeeTreeGrid.setIndentRecordComponents(true);
            employeeTreeGrid.setRecordComponentPosition(EmbeddedPosition.WITHIN);
    
            employeeTreeGrid.draw();
        }
    The record components are initially indented properly, however, if you reparent an item, the record component indentation does not change.

    Click image for larger version

Name:	drag_reparent_issue.JPG
Views:	55
Size:	15.1 KB
ID:	273226


    Thanks
    Last edited by stonebranch3; 9 Aug 2024, 07:51.

    #2
    I'm using SmartClient Version: v12.1p_2023-10-21/Pro Deployment (built 2023-10-21).

    Comment


      #3
      We'll check this out, but just a note, per the recordComponent docs, this is not a recommended way to use recordComponents - it's really inefficient to generate one whole Button per row when you could use the extraIcon or just an icon column for whatever actions you need to allow the end user to perform.

      But perhaps you are not actually doing this and it's just a test case.. either way, we'll check it out.

      Comment


        #4
        Thanks. I used a button similar to the Info button in the Cell Widgets showcase sample, however, it's just a test case to reproduce the issue.

        Comment


          #5
          This issue has been fixed. Please retest with tomorrow's build on Aug 20.

          Regards
          Isomorphic Software

          Comment


            #6
            Thanks! It's working as expected now.

            Comment

            Working...
            X