Sencha Inc. | HTML5 Apps

Blog

Countdown to Ext JS 4: Data Package

January 21, 2011 | Ed Spencer

Countdown to Ext JS 4: Data PackageOne of the areas that has seen the most improvement in Ext JS 4 is the data package. The data package enables you to retrieve, decode and use data in your applications. The data package has been completely rewritten for version 4, but it uses the same approach as previous versions. Today we're going to take a look at the new data package and see what it offers.

What's New

The data package in Ext JS 4 consists of 43 classes, but there are three that are more important than all others - Model, Store and Proxy. These are used by almost every application, and are supported by a number of satellite classes:

Data Package Overview in Ext JS 4

Models and Stores

The centerpiece of the data package is Ext.data.Model. A Model represents some type of data in an application - for example an e-commerce app might have models for Users, Products and Orders. At its simplest a Model is just a set of fields and their data. Anyone familiar with Ext JS 3 will have used Ext.data.Record, which was the precursor to Ext.data.Model. Let's look at how we create a model now:

 
Ext.regModel('User', {
    fields: [
        {name: 'id', type: 'int'},
        {name: 'name', type: 'string'}
    ]
});
 
Models are typically used with a Store, which is basically a collection of Model instances. Setting up a Store and loading its data is simple:
 
new Ext.data.Store({
    model: 'User',
    proxy: {
        type: 'ajax',
        url : 'users.json',
        reader: 'json'
    },
    autoLoad: true
});
 
That's all we need to do to load a set of User model instances from the url 'users.json'. We configured our Store to use an AjaxProxy, telling it the url to load data from and the Ext.data.Reader class used to decode the data. In this case our server is returning json, so we've set up a JsonReader to read the response. Stores are able to perform sorting, filtering and grouping locally, as well as supporting remote sorting, filtering and grouping. With Ext JS 4, there is no longer a separate GroupingStore - we can now do multi-sorting, filtering and grouping inside a standard Store:
 
new Ext.data.Store({
    model: 'User',
 
    sorters: ['name', 'id'],
    filters: {
        property: 'name',
        value   : 'Ed'
    },
    groupers: {
        property : 'age',
        direction: 'ASC'
    }
});
 
In the store we just created, the data will be sorted first by name then id; it will be filtered to only include Users with the name 'Ed' and the data will be grouped by age. It's easy to change the sorting, filtering and grouping at any time through the Store API.

Proxies

We saw above how Store uses a Proxy to load its data, and how that Proxy could in turn be configured with a Reader to decode the server response. One structural change in Ext JS 4 is that Store no longer has a direct link to Reader and Writer - these are now handled by the Proxy. This gives us an enormous benefit - Proxies can now be defined directly on a Model:
 
Ext.regModel('User', {
    fields: ['id', 'name', 'age'],
    proxy: {
        type: 'rest',
        url : '/users',
        reader: {
            type: 'json',
            root: 'users'
        }
    }
});
 
//uses the User Model's Proxy
new Ext.data.Store({
    model: 'User'
});
 
This helps us in two ways. First, it's likely that every Store that uses the User model will need to load its data the same way, so we avoid having to duplicate the Proxy definition for each Store. Second, we can now load and save Model data without a Store:
 
//gives us a reference to the User class
var User = Ext.getModel('User');
 
var ed = new User({
    name: 'Ed Spencer',
    age : 25
});
 
//we can save Ed directly without having to add him to a Store first because we
//configured a RestProxy this will automatically send a POST request to the url /users
ed.save({
    success: function(ed) {
        console.log("Saved Ed! His ID is "+ ed.getId());
    }
});
 
//load User 123 and do something with it (performs a GET request to /users/123)
User.load(123, {
    success: function(user) {
        console.log("Loaded user 123: " + user.get('name'));
    }
});
 
We've also introduced some brand new Proxies that take advantage of the new capabilities of HTML5 - LocalStorageProxy and SessionStorageProxy. Although older browsers don't support these new HTML5 APIs, they're so useful that we know a lot of applications will benefit enormously from their presence. And if we don't have a Proxy that matches your needs it's easy to create your own.

Associations

Proxies aren't the only new capability added to Models; we can now link Models together with the new Associations API. Most applications deal with many different Models, and the Models are almost always related. A blog authoring application might have models for User, Post and Comment. Each User creates Posts and each Post receives Comments. We can express those relationships like so:
 
Ext.regModel('User', {
    fields: ['id', 'name'],
 
    hasMany: 'Posts'
});
 
Ext.regModel('Post', {
    fields: ['id', 'user_id', 'title', 'body'],
 
    belongsTo: 'User',
    hasMany: 'Comments'
});
 
Ext.regModel('Comment', {
    fields: ['id', 'post_id', 'name', 'message'],
 
    belongsTo: 'Post'
});
 
It's easy to express rich relationships between different Models in your application. Each Model can have any number of associations with other Models and your Models can be defined in any order. Once we have a Model instance we can easily traverse the associated data - for example, if we wanted to log all Comments made on each Post for a given User, we can do something like this:
 
//loads User with ID 123 using User's Proxy
User.load(123, {
    success: function(user) {
        console.log("User: " + user.get('name'));
 
        user.posts().each(function(post) {
            console.log("Comments for post: " + post.get('title'));
 
            post.comments().each(function(comment) {
                console.log(comment.get('message'));
            });
        });
    }
});
 
Each of the hasMany associations we created above results in a new function being added to the Model. We declared that each User model hasMany Posts, which added the user.posts() function we used in the snippet above. Calling user.posts() returns a Store configured with the Post model. In turn, the Post model gets a comments() function because of the hasMany Comments association we set up. You may be wondering why we passed a 'success' function to the User.load call but didn't have to do so when accessing the User's posts and comments. All data is assumed to be loaded asynchronously because it usually has to be loaded from a server somewhere. This usually means passing in callbacks that are called when the data has been loaded, as with the 'success' function above.

Loading Nested Data

By setting up associations as we did above, the framework can automatically parse out nested data in a single request. Instead of making a request for the User data, another for the Posts data and then yet more requests to load the Comments for each Post, we can return all of the data in a single server response like this:
 
{
    id: 1
    name: 'Ed',
    posts: [
        {
            id   : 12,
            title: 'All about data in Ext JS 4',
            body : 'One of the areas that has seen the most improvement in Ext JS 4...',
            comments: [
                {
                    id: 123,
                    name: 'S Jobs',
                    message: 'One more thing'
                }
            ]
        }
    ]
}
 
The data is all parsed out automatically by the framework. It's easy to configure your Models' Proxies to load data from almost anywhere, and their Readers to handle almost any response format. As with Ext JS 3, Models and Stores are used throughout the framework by many of the components such a Grids, Trees and Forms.

Live Demo and More

We've set up a simple live demo for you to experiment with and placed it online. The demo uses the same Models that we set up in this post, but runs live code against a dummy data set. You can also download the live demo's source code and experiment yourself. We're currently in beta so there may be occasional bugs, but in general the data package is in a very robust state. To find out even more about the new data package and its new capabilities, I'd like to encourage you to sign up to our newsletter. We send it out about once a month and it always contains new articles on Ext JS and Sencha Touch that you can't find anywhere else (even on our blog) -- Sign up at the top of this page.

There are 79 responses. Add yours.

Zango

4 years ago

One more great news smile

I have a question:

What are efficient ways and practices of using new data package when you are using DWR request/response in all your application and have no traditional ajax requests handlers on server side.

I mean that DWR converts Java object into JavaScript (json) objects with all relationships (referenced objects). So, in that case, you do not need to define models with relationships on client side to be able to parse response that is complex structure of objects. In this case, how can we benefit using new data package model?

AwesomeBob

4 years ago

Wow this looks awesome! I love that you can nest response data and it will automatically be handled by the model relationships. This will save me a ton of time coding. One comment though, in the first example the data type for ‘name’ is ‘int’... Probably not what you wanted?

James Hughes

4 years ago

Good stuff.  I have 2 questions here though.

1. Will there be validations rather than on UI components?
2. Can associations be easily lazy loaded in some way?

Keep up the good work.

Alex

4 years ago

You just blew my mind!  This is awesome.

James Hughes

4 years ago

and the first question should have read

1. Will there be validations ON MODELS rather on UI components.

Loiane

4 years ago

Wow, I loved it! It’s going to make my life so much easier.

Mitchell Simoens

4 years ago

Can’t wait for this! Most people don’t realize that you can use a Proxy not only on a Store but a Model also. When should you a Model over a Store? Correct me if I’m wrong but I like to say that if you need to only load 1 record (Model) then use the Proxy on the Model, a Store should be used if you need to work with more than 1 record (Model).

Alex

4 years ago

@Mitchell,  good question. My thoughts are stores are used to manipulate the data you get back (sorters, filters, groupers) and to bind to the UI widgets. But I’d love some clarity from the dev team.

Westy

4 years ago

Looks excellent. I played with the Sencha Touch data APIs and was impressed then.

Unfortunately I think Ext 4 is going to be just that little too late for me to use this time around :(

Look forward to using it in the future though (or maybe will sneak in a port to 4 when I can)...

Erik R.

4 years ago

Very clever and clean design. Just what I’ve come to expect from Ext.

Tane Piper

4 years ago

These features look fantastic!  Our application uses a lot of relationships between models and currently I have to wait until all the data is loaded into the client side before we can display anything - hopefully this will make it much more efficient to do.

Leonardo J. Parra

4 years ago

‘Loading Nested Data’ excellent !

Tim Toady

4 years ago

Backwards compatibility?

Tane Piper

4 years ago

One thing I forgot to ask - will proxies and stores be as simple to extend as they are now?  The reason is, our application uses DNode which is a nodejs RPC implementation over socket.io, rather than traditional Ajax or ExtDirect.  Looking at it, I assume we can set up xtypes on proxies now for models?

Rob Boerman

4 years ago

Wow, excellent additions that will make a lot of common development issues much
Much easier!

You guys at Sencha rock.

Thomas Fritz

4 years ago

That is awesome! Great enhancement. I am really looking forward to the release!

Javier Rincon

4 years ago

Awesome

Michael Camden

4 years ago

I’m very impressed with this change. Keep up the good work!

Ed Spencer

4 years ago

@James Hughes - yup, validations are now on the *Model*, not in the UI. There’s actually more info on that in this month’s newsletter…

Can Associations be lazy-loaded? Absolutely. The HasManyAssociation actually returns a full Store:

user.posts(); <- this is a Store, automatically configured using the Post model

This means you have the full power of the new Store, with all its loading, sorting, filtering and paging capabilities.

Ed Spencer

4 years ago

@Mitchell use a Store whenever you’re dealing with more than one instance of your Model, just as you would in Ext JS 3. The benefit of allowing Model to use a Proxy directly is that we can now create, modify and delete single Model instances without a Store. This is really useful for reasons that will become apparent soon…

@Tim backwards compatibility is pretty good out of the box with the new data package, but I think with the addition of a legacy file we can get it even better

@Tane absolutely - extending these classes is easier than before

pablo

4 years ago

>> user.posts(); < - this is a Store

Can you explain some more about it?
Is it possible to add filters and sorters to it?
Can I define the posts store separately and assign it to the user model?

Are you going to support cross domain Ajax calls in IE
using the XDomainRequest object? It's impossible to add a support for it as an extension.

Extjs Events have delay config option. Could you support deadTime config option as well? Meaning that the event fires right away but then will wait some time before it fires again? For me deadTime makes more sense in UI.

Thanks

Alexander Hartmaier (abraxxa)

4 years ago

Loading nested data will integrate perfectly with DBIx::Class prefetches and Catalyst::Controller::DBIC::API, awesome!

Dmitriy Pashkevich

4 years ago

I’ve got a question that worries me: will there be ability to add multiple filters? Add and remove filters dynamically? This is absent in Ext 3 and I currently really miss this functionality. A serious data application is likely to have multiple filters applied to a Store and some may be turned off and on during runtime. It would be nice if the framework would handle this instead of leaving it to developer to manually compose his multiple filters in a single one and then calling Store.filterBy()...

And another one. As I read on the news I see that many features landing in ExtJS 4 are already present in Sencha Touch (like this Data package, HTML5 goodies, new theming system etc.). Is ExtJS4 seen and presented as the ‘desktop version of Sencha Touch’ and they will go further pretty close one to another or there will be fundamental differences, some stuff exclusively present in only one of two products?

Ed Spencer

4 years ago

@Dmitriy yes, multi-sorting, multi-filtering and multi-grouping are all changeable at any time. Ext JS 4 and Sencha Touch share a common base set of classes.

@pablo yes you can pass in a storeConfig to the association definition (which can include sorters, filters and anything else), and continue to modify user.posts() as you can with any other store.

Kevin Cho

4 years ago

Awesome stuff! Most likely, I’ll be able to upgrade to ExtJS 4 ^_^.  One thing that was puzzling was how a Reader was shared among different api in the Store.  For example, read & save.  If I have the control from server and the client, then I can sync the Reader on the inputs and outputs… but when that’s not the case.. I’m sort of screwed and only other option is to create seperate store for read/write.  For this release, is there a translation layer that would convert whatever Server’s json output to the ExtJS Model? That would be truly awesome!  Can’t wait for ExtJS 4!!!

soze

4 years ago

ExtJS 4 looks great but I have to ask, what fonts were used in the initial data diagram?

Alan Lindsay

4 years ago

This has a very narrow use case:

var message = user.posts().last().comments().last().get(‘message’);

This is much more powerful:

var commenters = user.posts().comments({property: ‘message’, value: ‘%awesome%’}).users();

Then I can quickly see who thinks my posts are awesome.

Michael Mullany

4 years ago

soze - the font is Klavika. If you like it, it’s available as a web font from http://processtypefoundry.com/fonts/klavika/

khebs

4 years ago

Hi, just a though, can ExtJS have a adapter/class to be compatible or work with StratifiedJS or Onilabs-Apollo? because since i have used sjs, things just so straight forward..

hafizan

4 years ago

1.Ya should used proxy instead of url because to handle exception if something server problem or error handling.

2.Filter ? A new hack.What will happen to GridFilter or it can co exist ?

Anyway the idea was cool.. smile

ibnesayeed

4 years ago

Now, I need not to learn ExtJS and Ruby on Rails separately! smile

Abdel

4 years ago

Excellent!! ExtJS 4 is getting more and more interesting! Great work by the development team smile

camelCase

4 years ago

The partial clipping of the last character typed in the email newsletter sign-up option top right of this page is not a good advert for Sencha LLC web design skills. (My browser = Chrome 8.0.552)

gevik

4 years ago

@ed
[1] The new Data Package will make life very easy. As for Ext4Yii this comes as a big blessing since the new Data Package can be directly mapped to Yii’s generated ActiceRecord model. For Yii (Ext4Yii) users out there, the way the new Data Package works is very natural.

[2] Another point that crosses my mind is whether we should use form posing at all, since all that can be done with model/proxy functionality from now. (form->getValues()->apply-to-Model->saveModel)

[3] Question: Is there anyway to map the Data model validation to form validation? Or do we have to configure validation for the form elements separately?

Thank you smile

Ed Spencer

4 years ago

@Kevin Not quite sure I follow - you mean you would have a different JSON format on /users.json and /users/1.json? You can still use a Reader to do that, you’d just have to create a small subclass to handle each format.

@Alan I may be able to work a syntax like that in, though it would probably look more like:

user.posts().comments().filter({property: ‘message’, value: ‘%awesome’})

@khebs I don’t see why not - no plans for any official support though

Ed Spencer

4 years ago

@hafizan Filters are not a hack, they replace a previous hack. In Ext JS 4, items like filters, sorters and groupers are all classes, which makes it much easier to reason about them strongly. GridFilter will build on Filter.

@gevik

1) Great!
2) Indeed - I prefer to do everything through the Model and just use the form for dumb data collection
3) Yes - if you configure a form with a Model it will ask the Model to validate itself, showing any errors on the appropriate field. This makes it easy to create very powerful validations

Valentin

4 years ago

Great news, actually great f*ckin news ;D

Resumen en español: ExtJS4: Data Package

Futch

4 years ago

If ExtJs 4.0 Chars will not be Flash/Flex then which Drawing Engine you will have ? is it SVG ? do users have to install SVG plugin ? who supports SVG?

Les

4 years ago

Ed, this is all very good news, but the Ext documentation needs to improve as well.  Take a look at the Highcharts doc.  Every HC option is not just described but it also links to multiple jsFiddle examples showing how to use it.  This is the kind of improvement I’d like to see in the Ext doc: provide usage examples for each config option, method, etc.

Search for “Try it” in the page below:

http://www.highcharts.com/ref/#plotOptions-area

mdev

4 years ago

If a model has multiple hasMany children, in the “loading nested data” example, how would it be possible for the framework to associate the proper hasMany definitions with the server response?

i.e.

User -> Posts -> Comments
User -> Notifications

Is the ordering that you define the hasMany relationships and the order of the JSON server response critical?

Vishal Kr Singh

4 years ago

Awesome!!! simply awesome, i love it more because i know how much effortless extjs4 is going to be. One request, don’t make it so simple else i won’t be able to call myself a coder. smile

André

4 years ago

Is there a data store, that contains “pages”. So that only page i, i - 1 and i + 1 gets store. The case is, that mobile devices suck, if you “store” a lot of data. It´s better to reload it, if you need it. So the store should drop old pages.

greetings Sunny

Ionatan

4 years ago

Is it me or the direction property of the sort is in the wrong place??

Tayfun Özi? Erikan

4 years ago

Awesome.
I love it! Just as delicious as ORM smile
Thanks.

Ian C

4 years ago

Hi Ed,
I noticed that if I change a json property to have an uppercase character then the data will fail to load.
For example, changing posts to Posts will prevent the data from loading.
Is there a workaround for this?
Apart from that, the new data package is very impressive!

Ed Spencer

4 years ago

@Futch - not flash, but not only SVG either. We have a solution that works on every supported browser. We’ll have an announcement and demonstration of this very soon.

@Les we’re working hard on that. Data docs massively improved on 3.x. Taking the same approach throughout the library

@mdev the Reader takes care of all that. Can have as many hasMany relationships as you want, nested to whatever level

Ed Spencer

4 years ago

@Andre Store does indeed take care of paging. It can be configured to only remember the current page, or to add each page to its loaded set as new pages are loaded

@Ionatan the example above doesn’t give a direction in the Sorter so it defaults to ‘ASC’. This example actually names two sort fields - name and id. Both will get the default ‘ASC’ direction

@Ian C yup - you can configure Reader with a custom property - see the ‘record’ and ‘root’ configurations under http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.JsonReader

LoreZyra

4 years ago

@Ed Spencer:
Can we have some news on Ext.draw classes??!

Ed Spencer

4 years ago

Soon, LoreZyra, soon smile

Simonli

4 years ago

Oh my god, it is really good, like ejb3

SpudNyk

4 years ago

Is it possible to have many to many relationships between 2 models by each saying hasMany of the other?

Indroniel Deb Roy

4 years ago

Most of the time for any moderately complex site there might be a ton of server side data structure which needs to be captured as models in Ext. Are you guys coming up with any code generation tools to get these models populated from server side objects ( POJO / XML Schema representation / DB schema representation etc.)
This will be a nice add-on to the Model infrastructure you have added to get stuff working rapidly with server side implementations. If not let me know and I might be able to help!
One more thing to add here, are the Models going to support data binding with UI controls? If not can we add some “Bindable” mixin in the UI controls to accomplish the same for the short term!! If you have any examples of data binding using mixins please share the code..

Mayank

4 years ago

Woot!
I can see some good coding skills.
This is going to make life so easy!

Imran

4 years ago

In large enterprise apps, the sheer number of classes gets extensive. Is it possible to add xtype like dot-notation Model reference names? We use java package-like structure names for our xtypes to keep things organized. I hope this can still be done.

For example:

Ext.regModel(‘com.etelligenceinc.User’, {
  fields: [
      {name: ‘id’, type: ‘int’},
      {name: ‘name’, type: ‘string’}
  ]
});

var User = Ext.getModel(‘com.etelligenceinc.User’);

AwesomeBob

4 years ago

My feed for your blog says Layouts is the next blog but when I click on the link I get a 404 on your site… What’s the deal with your blog feed?

Christiaan

4 years ago

In your example where you regModel User, you say hasMany: ‘Posts’ (plural). I dont see anything called Posts. I see a model called post (singular).

What’s the meaning of a hasMany property referring to something that does not exist in the example? I see the hasMany property adds the user.posts() function that upon calling returns a Store configured with the Post model. How does it know to take the Post (without the s) model?

The Sencha Touch API docs shows this (which makes more sense)
hasMany: {model: ‘Product’, name: ‘products’}

AwesomeBob

4 years ago

@Christiaan Good Catch… Two a’s in your name though?

yyogev

4 years ago

Looks very nice.

Any chance that with the introduction of groupers you’ll also add built-in support for multi-grouping in grids ?
We are using the multi-grouping grid user extension (http://www.sencha.com/forum/showthread.php?42454), but it has problems in ExtJS 3.3.

Nicolas BUI

4 years ago

Hi,

Overall, it’s cazy amazing piece of works ! Congratulation.

But i’m a bit worried about the migration from Ext 3.X.X to 4.X.X, it’s seems to require some amount of work.

I just saw two things in mind a bit annoying ...
the first is the proxy in the model. It’s seem to be nice as a shorcut but in design term, it’s not a concern for the model to care about data connection.
the second is the classes and model declaration, people that use IDE would be annoyed as only WebStorm/PhpStorm/IntelliJ would be able to parse structure.

Ed Spencer

4 years ago

@Indroniel the infrastructure to support that is already there, just a matter of tooling now. It’s on our radar

@Imran absolutely - that’s already supported

@AwesomeBob yea we pushed the button too quickly - it’s coming soon

Ed Spencer

4 years ago

@Christiaan That’s valid – Ext JS 4 has an Inflector which can pluralize and singularize automatically so it can figure the model out. It may be a little too much syntactic sugar though

@yyogev that’s the plan – may not make it to 4.0 though

@Nicolas that’s exactly why you specify a Proxy – the Model always has a consistent way of CRUDing itself without having to concern itself how. We’re working on a solution to the IDE issue

Ajay

4 years ago

@Christiaan That’s valid – Ext JS 4 has an Inflector which can pluralize and singularize automatically so it can figure the model out. It may be a little too much syntactic sugar though

@yyogev that’s the plan – may not make it to 4.0 though

@Nicolas that’s exactly why you specify a Proxy – the Model always has a consistent way of CRUDing itself without having to concern itself how. We’re working on a solution to the IDE issue

Christiaan

4 years ago

Wow, amazing inflector. I’m not native English but wtf about:
-Man becomes men
-Woman becomes women
-Fungus becomes fungi
-Thief becomes thieves (note that not all words ending in “f” follow this patttern: roof/roofs)
-Species remains species
-Medium becomes media
-Person becomes people
-And echoes, heroes, potatoes, vetoes vs autos, memos, pimentos, pros

(taken from: http://www.meredith.edu/grammar/plural.htm)

I would not rely nor expect the Ext framework to always find the corresponding Model defined in plural based on hasMany string property in singular. Don’t allow this and insist on hasMany: {model: ‘Product’, name: ‘products’}

Apart from this, I’m really keen on getting my hands dirty on 4.

ibnesayeed

4 years ago

@Christiaan: Rails way of handling this issue is to store exceptions and generalize the rest. If size of the dictionary matters, the list can be trimmed only to commonly used models.

QUESTION: Is local data paging support is in core now? Earlier we used to have Ext.ux.data.PagingStore by Condor to achieve this.

http://www.sencha.com/forum/showthread.php?71532-Ext.ux.data.PagingStore-v0.5

Chris Scott

4 years ago

@Ed Spencer:  Better get on that smile

//FIXME: this is not a good solution. Ed Spencer is totally responsible for this and should be forced to fix it immediately.

https://gist.github.com/801454

Data package looks great.

Gregor Streng

4 years ago

Hi,

I’m thrilled to read about all the new feature in ExtJs.
What’s about the release date?
Is end of February still feasible?

 

Christian Toma

4 years ago

Is there a way for the proxy to load data in multiple stores from a single request (eg ajax) ? For example I expose all my users and my products in a single request and I would like to load the information in two stores from that same request.

Will this functionality be available or it will require some aditional work ?

Poker Gratis

4 years ago

Discussão interessante aqui, post como aqui está dignificam a quem quer que aparecer neste sítio :/ 
Dá maior quantidade de este espaço, aos teus seguidores.

Elvis

4 years ago

I think the design improvements in Ext JS 4 look very good, but I have to ask what the best option is going to be for users who are in a position where they want to use Ext.data, but must load/store the data using JS functions, and it’s inappropriate for Ext to direct use XML, JSON or any AJAX, but simply use regular Object/Array values to get/send data. It would be nice to see Ext JS include a trivial proxy class that simply lets the programmer so whatever they need to to generate the Objects that Ext JS produces & consumes, without going through JSON/XML string conversions and similar tricks.

Also, I would strongly agree with Christiaan and suggest that you not provide the automatic pluralizer/depluralizer functionality by default. On many occasions I have created/found object models that use both singular and plural names for something—I may well have models called both ‘User’ and ‘Users’. Also, this seems to violate the principle of least surprise. As a user, I like when a program cleverly knows what I want; but as a developer, I prefer when code does only what I tell it to do.

Bojan Kraut

4 years ago

Nice improvement. But I’m still missing store dependencies. Master client relationships ...

Marino Bonetti

4 years ago

thats fantastic!!! Great job.
I have a question: is possible to define in the proxy the urls for different action like update or create??
Ex:
ed.save(); make a post request to the server, but is possible to define that the post request is /users/update
so we can define in the proxy the single CRUD urls:
Create-> users/new
Read->users/ (for all) users/1 for only the user whit id=1
Update -> users/update
Delete -> users/delete

Johan Maasing

4 years ago

I have a question about the RESTProxy. The documentation I looked at, hope it is relevant
http://dev.sencha.com/deploy/touch/docs
says in regards to create/POST:
“We’ll assume the creation went successfully and that the server gave this user an ID of 123”

It does not specify how the server returns the id.  This is a point where ExtJS traditionally has made some assumptions on RESTful services that is beyond what the HTTP-specification says. It is explained in a bug report for 3.0.3

http://www.sencha.com/forum/showthread.php?85946-CLOSED-3.0.3-DataReader.realize-expects-all-data-sent-to-server-to-be-returned&s=2468372a1bbcf66e293651a2f61e7afd

My question: is this fixed now? Can the server simply return 201 (without a body)  to indicate success and the location header set to return the ID?

Looking at the source (again, hope it is relevant, it is linked from touch/docs) I have problem following the extraction of the ID.

Brad Schafer

4 years ago

Any idea when a sample of the GridFilter in 4 will start to show up into the samples set?

Shama

4 years ago

Why model instance can be only join one store ?

Odili Charles Opute

4 years ago

This is so awesome, now am jealous of traditional JS development again, sometimes I think GXT is just playing catch-up with ExtJs, anyways, lets see what’s up when GXT 3 is released. Great job guys.

XML Editor

4 years ago

Idroniel if yuo want to look at the XML Schema there are tools out there taht will sync with your method to output an xml schema of your file.

Irene

4 years ago

Hi Ed,
Any suggestions on how in Ext JS 4 I can pass method name and arguments along with url , in Ext JS 3 you could use baseParams:
var store = new Ext.data.Store({
      storeId: ‘dimKeyStore’,
      autoLoad: true,
      url: ‘../../../classes/dimkeys/DimKeys.cfc’,
  baseParams: { method: ‘getDimKeys’, dbclient: ed.dm.clientschema},
  reader:dmReader )}
I check AjaxProxy API nothing similar could be found. Any suggestions?
Thanks in advance for help.

Aby Mathew

4 years ago

Ed, I am building a SOA foundation which pushes out validation along with the POCO pieces. However, I was looking at this and thinking if the readers can be dynamically created to populate the models. If the question was rephrased, what is the best way to map jsonp to the models.

Muthu

3 years ago

Hi,
The example provided uses the reader object in proxy.Please also provide a example for the writer object. How can we use post method and pass the json data as a paratmer.

Comments are Gravatar enabled. Your email address will not be shown.

Commenting is not available in this channel entry.