PDA

View Full Version : TreeLoader parameter mapping



esugovic
12 Jul 2010, 5:26 AM
I am evaluating ExtJS to be used on our future in-house projects and so far looks promising.

Took me a bit to acquire taste for declarative style that ExtJS promotes and just when
it started to feel natural, I stumbled upon a problem that cannot be resolved by simple
"key: 'value'" nitting.

Straight to the point: rigid TreeLoader. Its default implementation is too tight and
simply assumes too much:

"id", "text", "leaf"... correct me if I'm wrong but these are hardcoded values that
cannot be declaratively overridden (only via new implementation of createNode).

My point is: I can hardly imagine that a server-side purist is ever going to hardcode such
HTTP response just to acommodate presentation layer. On the other side, guy working on presentation
layer would be grateful if he had some basic plumbing to easily map "id", "text", "leaf"
to properties of arbitrary JSON encoded object returned by server.

Anyway, took me most of the day to figure out that there is no easy way around this.
I noticed that discussion on TreeLoader already took place:

http://www.sencha.com/forum/showthread.php?100686-DISCUSS-TreeLoader-needs-to-be-configurable.&highlight=custom+treeloader

Anyway, in case we go for ExtJS, I am casting my vote to definitely make TreeLoader more
flexible.

If I'm missing something here, feel free to give me a hint.

Thank you.

Condor
12 Jul 2010, 5:57 AM
Any input on making TreeLoader more flexible would be welcome.

The problem I see is that tree data from a server can come in just too many formats that could never fit into one generic solution.

IMHO it's better to make TreeLoader overrideable in a way that makes it possible to implement any format (e.g. have a look at the XML tree loader example).

esugovic
12 Jul 2010, 11:12 AM
Any input on making TreeLoader more flexible would be welcome.

The problem I see is that tree data from a server can come in just too many formats that could never fit into one generic solution.

IMHO it's better to make TreeLoader overrideable in a way that makes it possible to implement any format (e.g. have a look at the XML tree loader example).


Thank you very much for a swift reply.

Since I am new to ExtJS, I just pointed out to what seemed to me as deficiency in design.

Now that you mentioned XMLTreeLoader I see that I was probably expecting too much from a plain TreeLoader.
I would expect it to be some kind of abstract class with various concrete subclasses (XML, JSON, etc) which
are fully configurable. Since TreeLoader had actual implementation for reading data with predefined structure, I got
disappointed in its flexibility.

I'll try to implement createNode for start and then see how it goes. Maybe I'll implement JSONTreeLoader (or
named something like that) if I feel that 'force' is strong enough in me :)

I see someone already tried that (Thread: Ext.ux.tree.JsonTreeLoader), I'll look into it.

best regards.