Question

Hello good and smart pepoles.

I have couple of basic questions (I think) relating to ExtJS.

  1. As I was using the Ext.data.store object, I found out that it has assisting objects, such as Proxy, Reader, Writer, etc. So I tried, and tried again, but could not fing a satisfying explanation for what exactly is the use of this objects and what is the difference between them.

  2. The quesion above, leads me to the following one. I find my self struggling and spending days by days trying to realize how to use properly in the ExtJS framework. I mean, I can't find good documentation anywhere, and the plugins for known IDEs are far from easy to use. Does anyone has a good suggestion for how to use this framework? where can i see good examples?

To be more specific, Im trying to write simple application, that has a WINDOW contiaing 2 PANELS. One PANEL contains GRID with paging propery. The Other PANEL contains 2 TEXT FIELDS and couple of BUTTONS.

I need to align those components in reasonable order.

Very easy to define.

Very hard to implement.

Hope for better days :(

Thanks!

Was it helpful?

Solution

First, I would encourage you to read the docs on each of these--they fairly clearly explain what each is and the role that they play in the domain of dealing with "data" in Ext JS.

Here are some relevant links:

But to over-simplify the answer, here's a very high-level explanation.

Ext.data.Model: The Model simply represents an object that your application is going to know about and potentially interact with. By default, it's persistence is bound to your application's lifecycle. If you need to persist it beyond your application, you'll need to attach a proxy to it (more on this later).

Ext.data.Store: While stores are INCREDIBLY powerful, at the end of the day they are simply a cache of Model instances.

Ext.data.proxy.Proxy: The Proxy is the persistence level of the Ext.data.* package. With proxies, you can load Model instances from the server via AJAX, from LocalStorage, or even deal with Model instances completely in memory. All proxies, by default, provide a "CRUD" implementation, boiling down all interactions with Model instances to Create, Read, Update and Delete actions. While there are a variety of proxies to choose from, the all do the same thing: provide persistence management for your Model instances.

Ext.data.reader.Reader: The Reader, as its name implies, provides instruction for how data provided via the Proxy is supposed to be converted into Model instances. So for example, if you are loading data via Ext.data.proxy.Ajax, the reader will need to be configured to be able to "map" the response from the server into data that Ext JS can understand and cast into model instances. In other words, the Reader just provides instructions for how to convert data into Models.

Ext.data.writer.Writer: The Writer, as its name implies, is used by the Proxy to manipulate data before it is persisted. So for example, if you want data sent to the server in an AJAX request as XML, you could use the Ext.data.writer.Xml to send XML data; alternatively, you could use Ext.data.writer.Json to send JSON-encoded data.

Now, for all intents and purposes, most of this is fairly transparent. That is, if you are making generic CRUD requests that align with the data formats used in the Ext JS documentation, there is very little configuration with these that you will ever need to do. However, if you have exotic needs (either in terms of data received from the server [e.g., for the Reader] or how you should send the data [ e.g., for the Writer]), you can always create your own subclass of proxy, reader, or writer to achieve your goal. You will have to dig into the docs for the proper way to do this, but it's quite straightforward and there are a bunch of examples floating around in the Google-sphere.

Finally, regarding your question for examples, that will definitely depend on what you're trying to do. I would follow up with more specificity for particular issues that you're trying to address.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top