PDA

View Full Version : restful example in 'large application' style



Thumper
2 Nov 2009, 5:59 AM
There's a LOT going on in the "restful" data example - but it looks like a core building block I would be using in my application. I have successfully - I think - implemented some pre-configured classes for my overall layout and windows. Now I'm trying to begin actually working with data instead of "you clicked me" windows.

I'm still a bit confused on the constructor syntax for a many objects - which leaves me floundering when trying to subclass. A relatively simple example would be the JsonReader class. Can someone please give me an example of a pre-configured class using JsonReader - I think I can extrapolate from that for the other objects I'll need for my form.

Thanks in advance.

jsakalos
27 Nov 2009, 4:23 PM
Usually there is no need to extend Json Reader, but a higher level object. Grid, form, panel, tree, perhaps store, are the candidates.

firegun
9 Mar 2010, 1:58 PM
Thumper,

Im not really sure if what you trying to do is something similar to what Ill describe here. Where I saw the answer to that question, in truth where I found out what I was doing wrong, here (http://blog.extjs.eu/know-how/writing-a-big-application-in-ext-part-2/).

In my case I was trying to "pre-configure" the JsonStore, to setup some defaults properties. The problem is that most cases I could see on internet, reference to subclasses of Ext.Component, and Ext.data.JsonStore (and all stores classes) dont. Whats the solution so?



var myRestfulJsonStore = Ext.extend(Ext.data.JsonStore, {
constructor: function (config) {
Ext.apply(config, {
restful: true,
remoteSort: true,
root: 'rows',
totalProperty: 'rowsCount',
messageProperty: 'msg',
});

myRestfulJsonStore.superclass.constructor.apply(this, arguments);
}
});
As you can see, this is done on the class constructor, and not on the initComponent() method, witch is never called on classes not extending Ext.Component.

Im not sure that this is the best and only way to do it, for now is how I mananged to do that. (If some ExtJS dev see this and have another approach, plz plz let us know!)

I hope I was able to help in someway.

jsakalos
9 Mar 2010, 4:40 PM
The above approach is fully valid and recommended way consistent with the rest of Ext. Very well done!