VaR store = new Ext. Data. Store ({
URL: "Hello. xml ",
Reader: New Ext. Data. xmlreader ({
Record: "row "},
["ID", "name", "Organization", "Homepage"])
});
Because the sote component accepts a parameter URL, if the URL is set, extjs creates an ext. data. httpproxy object through the specified connection or ext. ajax. request to send a request to the server to read data from the server.
Experience shows that generating JSON data on the server is a very good choice, that is, if the server URL "student. EJF? Cmd = List "generates the following JSON data output:
{Results: [{ID: 1,
Name: 'wang ',
Email: 'xiaowang @ easyjf.com ',
Sex: 'male ',
Borndate: '2017-4-4 '},
{ID: 1,
Name: 'lily ',
Email: 'xiaoli @ easyjf.com ',
Sex: 'male ',
Borndate: '2017-5-6 '},
{ID: 1,
Name: 'Alan ',
Email: 'xiaoxiao @ easyjf.com ',
Sex: 'female ',
Borndate: '2017-3-7 '}
]
}
The store that displays the learning information editing table can be created in the following format:
VaR store = new Ext. Data. Store ({
URL: "student. EJF? Cmd = List ",
Reader: New Ext. Data. jsonreader ({
Root: "result "},
["ID", "name", "Organization", "Homepage"])
});
Or:
VaR store = new Ext. Data. jsonstore ({
URL: "student. EJF? Cmd = List ",
Root: "result ",
Fields: ["ID", "name", "Organization", "Homepage"]});
Root indicates the attribute that contains the record set data.
If you are runningProgramWhen sending data to the server, you can directly use the request method of the Ext. Ajax object provided in extjs. For exampleCodeImplement student. EJF? Cmd = save this URL to initiate a request and specify the student object to be sent in Params:
function SFN ()
{< br>
alert ('saved successfully ');
}< br>
function FFN ()
{< br>
alert ('Save failed ');
}< br>
Ext. ajax. request ({
URL: 'student. EJF? Cmd = save '
success: SFN
failure: FFN,
Params: {Name: 'lil', email: 'xiaoli@easyjf.com ', borndate: '1992-5-6', sex: 'male'}
});