Results 1 to 4 of 4

Thread: How to expand a Tree

  1. #1
    Sencha User
    Join Date
    Mar 2020
    Posts
    15
    Answers
    1

    Default Answered: How to expand a Tree

    I have written a test that doesn't fail when I run it but it also doesn't expand the tree like I was expecting it to.

    The screen print below shows what I am trying to expand (as shown by the arrow) so that I can get on the second level and then select the next row in the tree.

    Annotation 2020-06-01 153012.jpg

    Here is my test, that does selects the correct row but I was hoping it would click on the 'x=tree-elbow-plus' icon and expand the tree. When the test runs it doesn't click on the icon so the row doesn't expand, but the test does run without any errors.

    Code:
    it('should expand Export control under Security', function() {
            ST.grid('graphnavigator[reference="graphnavisecurity"]:last')
                .rowWith('rid', 'root-ExportControl')
                .reveal()
                .cellAt(0)
                .click();
        });
    Can anyone see what I am doing wrong?

    Thanks.

  2. I have figured this out myself. I just needed to add a line of code so that the image is clicked and it works exactly as I expected:

    Code:
    it('should expand Export control under Security', function() {
            ST.grid('graphnavigator[reference="graphnavisecurity"]:last')
                .rowWith('rid', 'root-ExportControl')
                .reveal()
                .cellAt(0)
                .down('.x-tree-elbow-img')
                .click();
        });

  3. #2
    Sencha User
    Join Date
    Mar 2020
    Posts
    15
    Answers
    1

    Default

    I have figured this out myself. I just needed to add a line of code so that the image is clicked and it works exactly as I expected:

    Code:
    it('should expand Export control under Security', function() {
            ST.grid('graphnavigator[reference="graphnavisecurity"]:last')
                .rowWith('rid', 'root-ExportControl')
                .reveal()
                .cellAt(0)
                .down('.x-tree-elbow-img')
                .click();
        });

  4. #3
    Sencha User
    Join Date
    Mar 2017
    Posts
    46

    Default

    Glad you figured it out. I have a helper function to handle all tree expansions for my suite. This function takes my tree locator function then just expands all nodes within it. I'm sure you could modify it to target specific rows if needed.

    Code:
    expandAllForTree: function(treeLocator) {
    treeLocator().execute(function(grid) {
    var rootNode = grid.getStore().getRoot();
    rootNode.expand();
    rootNode.expandChildren(true).wait(1000);
    });
    },

  5. #4
    Sencha User
    Join Date
    Mar 2020
    Posts
    15
    Answers
    1

    Default

    Thanks very much swillo, I shall have a look at your code but I am certain that will be very helpful!

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •