PDA

View Full Version : How to make store with several records?



maxkliver
25 Nov 2012, 10:09 PM
I want to create Ext.data.store with several data sets. Using store like this:


store_form = new Ext.data.Stor
url: url_servlet+"kadastr_zemform.jsp?ss="+<%=str%>,
reader: new Ext.data.XmlReader({
totalProperty: "results",
record: "zem",
fields: [
{name: 'cadastr', mapping:'parcel/preview/cadastr'},
{name: 'address', mapping:'parcel/preview/address'},

{name:'res', mapping:'really/preview/res'},
{name:'zem_kod', mapping:'really/preview/zem_kod'},

{name: 'right_type_docs', mapping:'doc/preview/right_type_docs'},
{name: 'doc_docs', mapping:'doc/preview/doc_docs'},

];

This store used by 3 FormPanels: 1 for parsel, 2 for really, 3 for doc. And, for example, if on one parcel exists several real estate i want show one by one. i mean i show first then click button and show next.
Questions:

1. For this i need XML with several `zem` records?
2. How to create this XML? Now i can create XML with only one record couse:


out.print(<zem>);
Statement st1=<query to parcel table>;
while(ResultSet.next()){
out.print(<parcel>);
out.print(<parcel table fields>);
out.print(</parcel>);
}
st1.close();
Statement st2=<query to really table>;
while(ResultSet.next()){
out.print(<really>);
out.print(<really table fields>);
out.print(</really>);
}
st2.close();
Statement st3= <query to docs table>;
while(ResultSet.next()){
out.print(<doc>);
out.print(<doc table fields>);
out.print(</doc>);
}
st3.close();
out.print(</zem>);

jorgeluislay
26 Nov 2012, 3:29 PM
can you give more code ?

maxkliver
26 Nov 2012, 9:52 PM
Now its converted in another question: How to take data from store?
I can take record from store: var record = store.getAt(i);
But if i want to take fileds which have a same name from record i get only first field value. For example if i have XML with:


<zem>
<parcel>
....
<parcel>
<really>
<price>555.555<price>
</really>
<really>
<price>666.666<price>
</really>
</zem>

And using record.get("price") i can get only 555.555 value.
Its possible to get values of all fields of <really>? Or array of all <price> fields?

willigogs
27 Nov 2012, 12:00 AM
Have you tried using query:
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-query

maxkliver
27 Nov 2012, 9:10 PM
Thank you. Its look like what i need.