Results 1 to 5 of 5

Thread: Loading extjs tree nodes data on demand

  1. #1

    Default Loading extjs tree nodes data on demand

    Hi,

    I am a newbee to Ext js.I am using extjs 4.0 version. Below is my extjs-treegrid.js.

    I would like to know, how could I achieve on demand load of data whenever the child nodes are clicked.
    Basically, I want to load only configurable records from json file to my tree grid and on click of the any of the childnodes(or any node) I want to load all the records from the same/different json file. I mean asyncronous load.

    An extjs java script example will be much helpful/any examples we have at sencha.
    Kindly help.

    Code:
    Ext.onReady(function() {
     Ext.define('MyModel', {
          extend: 'Ext.data.Model',
          fields: fdata // this variable holds all the fields
      });
        var store = Ext.create('Ext.data.TreeStore', {
            model: 'MyModel',
            proxy: {
                type: 'ajax',
                url: 'myJson.json'
            } ,
            autoload:false,
            folderSort: true
        });
        var grid = Ext.create('Ext.tree.Panel', {
            store: store,
            height: 400,
            width: 970,
            renderTo: 'divarea',
            expanded: true,
            useArrows: false,
            rootVisible: false,
            loadMask: true,
      columns: coldata//this variable holds all the columns correctly mapped with dataIndex
        });
    });

    Thanks,
    Ashu
    Last edited by mitchellsimoens; 20 Mar 2012 at 9:36 AM. Reason: added [CODE] tags

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    If a node is not a leaf but has no children specified, then when you expand the node it should fire off a request to load the children.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3

    Default

    Thanks for the reply. Could you plz guide me if we have any such examples on sencha docs or with code snipppet to achieve it.

    Thanks in advance.

  4. #4

    Default

    Please see the post below.. I want to achieve exactly the same in extjs 4.

    http://stackoverflow.com/questions/3...grid-on-demand


    I tried the below code snippet in my script.

    root : new Ext.tree.AsyncTreeNode({text: 'Root'}),
    loader: new Ext.tree.TreeLoader({
    dataUrl: 'myNewJson.json' }),

    It is not working, when I dig into the sencha extjs 4 docs. I do not find AsyncTreeNode or TreeLoader.

    Also, on the above thread they shared below sencha link (which is throwing 404 Not found)
    http://dev.sencha.com/deploy/ext-4.0...d/treegrid.htm


    Thanks,
    Ashu

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Location
    Ukraine
    Posts
    154
    Answers
    11

Posting Permissions

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