ext treestore auload失效问题

来源:互联网 发布:mp5刷机软件 编辑:程序博客网 时间:2024/05/11 12:04

  • Products
  • Support
  • Training
  • Company
  • Blog
  • Contact
  • Store
  • Log in / Register
  • Forum
  • App Gallery
  • Learn
  • Documentation
Forum / Ext JS Community Forums 4.x / Ext: Q&A /

autoLoad: false TreeStore in with TreePanel rootVisible: false

+ Reply to Thread

  • Thread Tools
  • Search Thread
  • Display
  1. #1
    fabio.policeno 
    fabio.policeno is offline
    Sencha Userfabio.policeno's Avatar
    Join Date
    Sep 2010
    Location
    Curitiba - PR / Brasil
    Posts
    214
    Vote Rating
    0
    Answers
    8
    fabio.policeno is on a distinguished road

     0 

    Unanswered: autoLoad: false TreeStore in with TreePanel rootVisible: false


    Hello, I understand the idea of ​​autoLoad: false TreeStore the "no work" or work differently due to the expansion of the root. But if you do not want to display this root, there's no way I set it so that it is not expanded, since it is hidden. The main problem is I need to load the tree after it is rendered, but it strikes me the following error:

    Code:
    records[i] is undefined...ns[i].viewRecordId = records[i].internalId;
    Moreover, it tries to create new nodes instead of removing the existing and doing a "reload" menu.To better illustrate the problem, I created the example below.

    Code:
    <!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <link rel="stylesheet" href="../resources/css/ext-all.css" type="text/css">        <script type="text/javascript" src="../ext-all-dev.js"></script>        <script type="text/javascript">            Ext.define('Menu', {                extend: 'Ext.data.Model',                fields: [                    {name: 'id', type: 'int'},                    'text',                    'leaf'                ],                proxy : {                    type  : 'ajax',                    url      : 'menu.json',                    reader: {type: 'json'},                }            });                    Ext.onReady(function() {                var store = Ext.create('Ext.data.TreeStore', {                    model    : 'Menu',                    autoLoad: true                });                Ext.create('Ext.tree.Panel', {                    renderTo   : Ext.getBody(),                    height       : 100,                    store       : store,                    rootVisible: false                });                                store.load();            });        </script>    </head>    <body>    </body></html>
    menu.json
    Code:
    [{    id    : 1,    text: 'Menu 1',    leaf: true},{    id    : 2,    text: 'Menu 2',    leaf: true}]
    Ext JS 4.0.7

    Thank you!
    Automatic Generator of Applications Ext JS 4
    Reply With QuoteReply With Quote
  2. #2
    mitchellsimoens 
    mitchellsimoens is online now
    Sencha - Senior Forum Managermitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    27,805
    Vote Rating
    325
    Answers
    2533
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

     0 


    If you wanted to stop the loading you can return false in a beforeload event listener. Then to load you can do

    Code:
    store.load({    node : rootnode});
    Mitchell Simoens
    Sencha Inc, Senior Forum Manager
    @SenchaMitch

    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription.https://www.sencha.com/store/

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in heavy development! Several chapters already available!
    Reply With QuoteReply With Quote
  3. #3
    fabio.policeno 
    fabio.policeno is offline
    Sencha Userfabio.policeno's Avatar
    Join Date
    Sep 2010
    Location
    Curitiba - PR / Brasil
    Posts
    214
    Vote Rating
    0
    Answers
    8
    fabio.policeno is on a distinguished road

     0 


    As specifically stop load? return false just before the load is not going to stop .. I do not understand your code .. I put in the rootnode, if I do not want the menu has a root?
    Automatic Generator of Applications Ext JS 4
    Reply With QuoteReply With Quote
  4. #4
    mitchellsimoens 
    mitchellsimoens is online now
    Sencha - Senior Forum Managermitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    27,805
    Vote Rating
    325
    Answers
    2533
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

     0 


    Code:
    store.on('beforeload', function() { return false; });
    then...

    Code:
    store.load({    node : store.getRootNode()});
    Mitchell Simoens
    Sencha Inc, Senior Forum Manager
    @SenchaMitch

    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription.https://www.sencha.com/store/

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in heavy development! Several chapters already available!
    Reply With QuoteReply With Quote
  5. #5
    fabio.policeno 
    fabio.policeno is offline
    Sencha Userfabio.policeno's Avatar
    Join Date
    Sep 2010
    Location
    Curitiba - PR / Brasil
    Posts
    214
    Vote Rating
    0
    Answers
    8
    fabio.policeno is on a distinguished road

     0 


    Code:
    Ext.define('Compstoque.view.Menu' ,{    extend       : 'Ext.tree.Panel',    alias      : 'widget.mainmenu',    region     : 'west',    title       : 'Menu',    width       : 200,    minWidth   : 150,    maxWidth   : 400,    split       : true,    collapsible: true,    store       : 'Menu',    rootVisible: false});
    Code:
    Ext.define('Compstoque.store.Menu', {    extend: 'Ext.data.TreeStore',    model : 'Compstoque.model.Modulo'});
    Code:
    ...'mainmenu'          : {                render     : me.loadMenu,                ...            },...loadMenu: function(tree) {        var store = tree.getStore();                store.on('beforeload', function() {return false;});        store.load({            node : store.getRootNode()        });    },
    not really loads the menu, but he keeps doing the requests, including a need to "reload" on the menu with other data, but is not occurring. Even several requests being made unnecessarily. In short, I want to load the menu in store only at render, this method LoadMenu, but I'm not getting.

    store.jpg
    Automatic Generator of Applications Ext JS 4
    Reply With QuoteReply With Quote
+ Reply to Thread
原创粉丝点击