Access data of Ext. data. store

Source: Internet
Author: User
I have read more than N documents and read many forums over the past two days. I plan to solve the problem of reading data from the store. At the beginning, I can read data from the store returned in Json, however, xml cannot be used. what I want is how to read data from xml, so I have been looking for such a similar method. We can see store from its api. getAt (0) method, but if we use this method directly, an error occurs, prompting that the data contained in the getAt function is null, therefore, we cannot obtain specific data when tracking js. here, firefox is used to track the execution process of js, which is very easy to use. We recommend that you also use it. for Ext, its documentation may be a reference for people who are very familiar with Ext. For Beginners, the reference is of little value, and sometimes it is easy to mislead, so we are always in a bumpy state when learning Ext. or this is why people will pay for it in the future. After all, it is an open-source item, and the attributes and Methods prompted by Ext documents are correct.

Today, I accidentally found a post with the same problem as me In the Ext Forum. Finally, he solved the problem and I also solved it by the way. but he didn't paste his code, so I am pasting my code for reference.

This is an Xml document

 

<? Xml version = "1.0" encoding = "UTF-8"?>
<Items>
<Item input = "Connect. Host" value = "value. Connect. Host"/>
<Item input = "Connect. DB" value = "value. Connect. DB"/>
<Item input = "Connect. User" value = "value. Connect. User"/>
<Item input = "Connect. Password" value = "value. Connect. Password"/>
</Items>

 

The following is the js Code:

 

Var ds = new Ext. data. Store ({
Proxy: new Ext. data. HttpProxy ({url: 'test1. xml', method: 'get '}),
Reader: new Ext. data. XmlReader (
// Records will have an "Item" tag
{Record: 'item '},
[
// Set up the fields mapping into the xml doc to extract * attributes *
{Name: 'value', mapping: '@ value '},
{Name: 'input', mapping: '@ input '}
])
});
Ds. on ('load', AJAX_Loaded, this, true); // note this
Ds. load ();
 
Function AJAX_Loaded (){
Alert (ds. getCount ());
For (var I = 0; I <ds. getCount (); I ++ ){
Var rec = ds. getAt (I );
Alert ("value = '" + rec. get ("value "));
Alert ("input = '" + rec. get ("input "));
}
}

 

It should be noted that the data we get is implemented through the load event, which is a lot of errors. That is to say, if we do not get data through the event, we still cannot get data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.