Results 1 to 3 of 3

Thread: Trouble with tree store

  1. #1
    Sencha User
    Join Date
    Nov 2019
    Posts
    4

    Default Trouble with tree store

    I am trying to use the restful example to load data into a tree store. I'm partially successful, but when you click on any parent item that has children, all that happens is that instead of expanding and showing the children it indents inward.

    Before click:
    Screen Shot 2019-11-20 at 4.28.21 PM.png
    One click:
    Screen Shot 2019-11-20 at 4.29.14 PM.png
    Another click:
    Screen Shot 2019-11-20 at 4.29.56 PM.png

    The numbers in parenthesis are how many children there should be inside.

    Example json output from my php script:
    Code:
    {"success":true,
    "message":"Loaded courses",
    "data":[
        {
            "id":"11060",
            "section":"0100",
            "meeting":"M W     14:00:00 15:15:00 IV   THEA1",
            "course":"ANTH 0002 (22)",
            "children":[
                {"id":"11061","course":"ANTH 0002","meeting":"  W     08:00:00 08:50:00 HSSB 1237","leaf":true},
                {"id":"11062","course":"ANTH 0002","meeting":"M       17:00:00 17:50:00 HSSB 4201","leaf":true},
                ...
                {"id":"11082","course":"ANTH 0002","meeting":"   R    17:00:00 17:50:00 HSSB 4202","leaf":true}
            ]
        },
        {
            "id":"11083",
            "section":"0100",
            "meeting":" T R    17:00:00 18:15:00 BRDA 1610",
            "course":"ANTH 0007 (9)",
            "children":[
                {"id":"11085","course":"ANTH 0007","meeting":"M       16:00:00 16:50:00 GIRV 2116","leaf":true},
                ...
                {"id":"11089","course":"ANTH 0007","meeting":"  W     18:00:00 18:50:00 LSB  1101","leaf":true}
            ]
        }
       ect....
    ]}
    I'm loading the data on the fly when you click on an item corresponding to the department in a list that displays in another region of a view.
    The selectionchange event is loading the data:

    Code:
    selecteditems = selmodel.getSelected().items[0].data;
               var coursesStore = Ext.getCmp('CoursesGrid').getStore();// pass in the id of the thing
               coursesStore.setProxy({
                       type: 'rest',
                       url: WWROOT+'/lib/app.php/courses',
                       extraParams: {  
                           quarter: localStorage.getItem("Quarter"), 
                           department: selecteditems.id
                       },
                       reader: {
                           type: 'json',
                           rootProperty: 'data',
                           successProperty: 'success'
                       }
                   });
               coursesStore.load();
    I've probably done this all wrong, but I can't figure out how else to do it.

  2. #2
    Sencha Premium User abutnar's Avatar
    Join Date
    Dec 2015
    Location
    Cluj-Napoca, Romania
    Posts
    12

    Default

    When you click on a parent item and a server request is made, does the answer contain only it's children?

  3. #3
    Sencha User
    Join Date
    Nov 2019
    Posts
    4

    Default

    I think I figured it out that the array keys I was sending were the problem. The array keys have to be basic indices, not something like an internal unique key.

Posting Permissions

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