Project has special requirements: There is an applet on the page, which is responsible for retrieving data from some clients to the page. The data format is an XML string.
After reading these XML strings in JS on the page, they must be displayed in the gird of Ext.
The problem is: whether in the ext example or in the document, the XML Information loaded by the grid store is stored in an XML file. Only data in array or JSON format on the page is accepted by store. xml strings or DOM objects are not directly loaded.
Later, I found the answer in the extjs official forum. The solution is to encapsulate the XML string into a DOM object, and then use Ext. Data. memoryproxy as the proxy.
The excerpt is as follows:
// Load XML as string
VaR Strxml = " <Tags> </tags> " ;
VaR Xmlobject;
// Load XML string code for IE
If (Window. activexobject)
{
VaR Doc = New Activexobject ( " Microsoft. xmldom " );
Doc. async = " False " ;
Doc. loadxml (strxml );
}
// Load XML string code for Mozilla, Firefox, opera, etc.
Else
{
VaR Parser = New Domparser ();
VaR Doc = Parser. parsefromstring (strxml, " Text/XML " );
}
Xmlobject = Doc.doc umentelement;
//
VaR Datastore = New Ext. Data. Store ({
Proxy: New Ext. Data. memoryproxy (xmlobject ),
Reader: New Ext. Data. xmlreader ({
Record: ' Item ' ,
ID: ' Itemid '
},[
' Cat1 ' , ' Cat2 ' , ' Cat3 ' , ' Cat4 '
])
});
//Etc. etc.