最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - EXTJS4 - For TreeStore, how to pass parameters and action methods? - Stack Overflow

programmeradmin2浏览0评论

I am using Extjs4 TreeStore, i want to know how to pass parameters (like mode = 'list') and action methods (POST or GET).

Thanks in advance.

EXTJS 3.x i have used like this it's working fine:

loader: new Ext.tree.TreeLoader({
    dataUrl: 'content/permissions/server.php',
    baseParams: {
        mode: 'getPermissions'
    }
})

EXTJS 4.x i have used like this but it is not working:

Ext.create('Ext.data.TreeStore', {
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'server.php'
    },
    extraParams: {
        mode: 'getTree'
    },
    actionMethods: 'POST',
    root: {
        text: 'Tree',
        id: 'src',
        expanded: true
    }
});

Thanks, Riyaz

I am using Extjs4 TreeStore, i want to know how to pass parameters (like mode = 'list') and action methods (POST or GET).

Thanks in advance.

EXTJS 3.x i have used like this it's working fine:

loader: new Ext.tree.TreeLoader({
    dataUrl: 'content/permissions/server.php',
    baseParams: {
        mode: 'getPermissions'
    }
})

EXTJS 4.x i have used like this but it is not working:

Ext.create('Ext.data.TreeStore', {
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'server.php'
    },
    extraParams: {
        mode: 'getTree'
    },
    actionMethods: 'POST',
    root: {
        text: 'Tree',
        id: 'src',
        expanded: true
    }
});

Thanks, Riyaz

Share Improve this question asked Jun 21, 2011 at 12:34 Riyaz AhamedRiyaz Ahamed 652 gold badges2 silver badges6 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

You should carefully check your configuration parameters with the current Ext JS 4 API Documentation.

What I see at first glance:

  1. actionMethods is an object and not a string value configuration. It's implemented in both the AJAX and the REST proxies. If your need a full featured editable tree, consider a REST proxy. Only if you go beyond CRUD, you need to provide additional actionMethods to the REST proxy.

  2. extraParams belongs to the Proxy and not to the tree configuration.

So your store configuration should look like:

Ext.create('Ext.data.TreeStore', {
  autoLoad: true,
  proxy: {
    type: 'ajax',
    url: 'server.php',
    extraParams: {
      mode: 'getTree'
    },
  },
  root: {
      text: 'Tree',
      id: 'src',
      expanded: true
  }
 });

Have you verified if at least an Ajax request has been sent to the server? You can easily check this with FireBug.

example of correct setting:

  actionMethods: {
                destroy:'DELETE',
                create: 'POST',
                update: 'POST',
                read: 'GET'
            },

This the correct one

Ext.create('Ext.data.TreeStore', {
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'server.php',
        extraParams: {
            mode: 'getTree'
        },
        actionMethods: 'POST'
    },
    root: {
        text: 'Tree',
        id: 'src',
        expanded: true
    }
});
发布评论

评论列表(0)

  1. 暂无评论