Results 1 to 8 of 8

Thread: TreeStore loading on demand

  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    112
    Vote Rating
    1
      0  

    Default Answered: TreeStore loading on demand

    Hi,

    I have a tree, which I wan't to be able to lazy load. When a user clicks the expand button, a request should be made. And the data should be added to the tree as a subfolder. It current works now, if you start from scratch.
    But lets say a user navigates in trough a history url (#siteName/documentLibrary/). The first level is loaded correctly. (siteName). A new request is automatically made with the #siteName/documentLibrary" as path, which should load the 2 subfolders this folder has. The server returns the correct amount of folders, but for some reason, they are added twice to the tree. Which corrups the tree, and making it do all sort of strange things. See image below.

    tree.jpg

    There request has been made only once, so there seems to be no problems at serverside. So can anyone help with this issue? Sorry for a bad explanation :P

    Frank

  2. I had this once .. but forgot what it was exactly. But, can you check if the id's of your nodes are unique in your tree. Every node should have a unique id. Else you get troubles...and I think this one.

    Whats under node links? frank and test234 with the same ids as under documentLibrary?

    One of the problem was you cannot expand odes anymore .. and probably double nodes.

  3. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,199
    Answers
    87
    Vote Rating
    44
      0  

    Default

    I had this once .. but forgot what it was exactly. But, can you check if the id's of your nodes are unique in your tree. Every node should have a unique id. Else you get troubles...and I think this one.

    Whats under node links? frank and test234 with the same ids as under documentLibrary?

    One of the problem was you cannot expand odes anymore .. and probably double nodes.

  4. #3
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    112
    Vote Rating
    1
      0  

    Default

    ID is unique as I can see. But I get an exception now:

    Uncaught TypeError: Cannot read property 'internalId' of undefined

  5. #4
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,199
    Answers
    87
    Vote Rating
    44
      0  

    Default

    for that one you must post some code....

  6. #5
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    112
    Vote Rating
    1
      0  

    Default

    Thats just it, I don't know where to start :P

    I can atleast provide som code about my models and stores.

    Code:
    Ext.define('app.store.DocumentLibraryNavigation', {	extend: 'Ext.data.TreeStore',
    	
    	model: 'app.model.Folder',
    	autoLoad: false,
    	proxy: {
    		requestMethod: 'GET',
    		type: 'ajax',
    		url: 'services/folder/childrenDynamic',
    		reader: {
    			type: 'json',
    			root: 'data'
    		}
    	},
    	root: {
    		text: 'root'
    	}
    });
    Code:
    Ext.define('app.model.Folder', {	extend: 'Ext.data.Model',
    	fields: [
        	{ name: 'name', type: 'string' },
        	'title',
        	'description',
        	'nodeType',
    //    	{ name: 'id', mapping: 'path'},
        	{ name: 'nodeRef', type: 'string'},
        	{ name: 'items', type: 'auto'},
        	{ name: 'path', type: 'string'},
        	{ name: 'cls', mapping: 'cls'},
        	'iconCls'
    	]
    });
    I've uncommented the ID part, because I'm setting it serverside instead. But I think there is some issues with the ID or something, but i can't figure out where. Is it a extjs bug?

  7. #6
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    112
    Vote Rating
    1
      0  

    Default

    this is the code that fails.. its in ext-debug-all.js

    updateIndexes method:
    Code:
    for(var i = startIndex; i <= endIndex; i++){            
    ns[i].viewIndex = i;
    ns[i].viewRecordId = records[i].internalId;
    ext-all-debug.js:58747Uncaught TypeError: Cannot read property 'internalId' of undefined
    ext-all-debug.js:58747Uncaught TypeError: Cannot read property 'internalId' of undefined
    ext-all-debug.js:58747Uncaught TypeError: Cannot read property 'internalId' of undefined
    ext-all-debug.js:58747Uncaught TypeError: Cannot read property 'internalId' of undefined
    ext-all-debug.js:58747Uncaught TypeError: Cannot read property 'internalId' of undefined
    if (!ns[i].boundView) {
            ns[i].boundView = this.id;
    }
    }

  8. #7
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,199
    Answers
    87
    Vote Rating
    44
      0  

    Default

    What happens if you specify the idProperty on the reader? Fill in there where to find the id in the returned JSON.

  9. #8
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    112
    Vote Rating
    1
      0  

    Default

    I managed to solve my problem. The issue was with my code which auto expanded rows with the path from history. It was called a couple of times, with the same path, which produced all kinds of wierd behaviour.

    Thanks for the help tvanzoelen!

Posting Permissions

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