views:

606

answers:

2

How I can modify that example http://www.extjs.com/deploy/dev/examples/tree/reorder.html
for RESTful support?

When we click on some node, it sends POST as "node=src/dd", but it doesn't work for RESTful.
It should be for example as "node/src_dd", and GET will be nice.

I found that ExtJS support RESTful for Store.
http://www.extjs.com/deploy/ext-3.0-rc2/examples/restful/restful.html

Thanks,

+2  A: 

You'll have to create your own custom TreeLoader class to construct the node names RESTfully in the url instead of passing 'node' as a param. As you can see from this example code, specifying your own TreeLoader allows you to easily specify the HTTP request method.

root: new Ext.tree.AsyncTreeNode({
  expanded: true,
  loader: new Ext.tree.TreeLoader({
    url: '/sample-data-toc.json',
    requestMethod: 'GET',
    preloadChildren: true
  })
})

Dig into the TreeLoader class and extend it to provide your own url scheme.

EDIT: after looking at the TreeLoader source, it looks like you should override requestData to properly set the url based on the node, and you'll probably want to change getParams to either return nothing or any special query string params you have. Should not be too much work. When you're done, share back your RESTfulTreeLoader with the community!

Jonathan Julian
A: 

Thanks for reply. I was able to do that, but there are a lot of code (~150 lines) and looks not very elegant... Need to be overwrite the follow classes:

Ext.tree.TreeLoader, Ext.data.Connection,

and create own urlEncode & urlAppend functions.

I think feature like native support RESTful should be added to ExtJS idrectly, as this way is not a solution... Could be regressions if ExtJS library will update...

I'll share code in 1 week when I test it more detailed...

Alex Ivasyuv
Did you ever end up posting this code anywhere ? I'd be interested in seeing it
SBUJOLD