I am trying to load the following xml data rendered from a JSP page and display the name, city , state and hide zip. How do I do it in dojo? I have trie开发者_StackOverflow中文版d some code , but have not made any big progress. The code works for JSON data.
XML DATA rendered from a JSP/Servlet
customers/ /customer /name/JOHN DOE/name/ /city/SFO/city/ /state/CA/state/ /zip/94087/zip/ /customer /customer /name/SUSAN SMITH/name/ /city/CHICAGO/city/ /state/IL/state/ /zip/61706/zip/ /customer/ /customers/
JAVASCRIPT CODE
// make request to the customers web service function loadTable(page){
var targetURL = "test.jsp";
dojo.xhrGet({
url: targetURL,
handleAs: "xml",
mimetype: "text/xml",
load: handleResponse,
error: handleError
});
}
var view1 = { cells: [ [ {name: 'Company', field: "name"}, {name: 'City', field: "city"}, {name: 'State',field: "state"}, {name: 'Zip',field: "zip"} ] ] }; // a grid layout is an array of views. var layout = [ view1 ]; // the model will contain the data to be displayed in the view model = new dojox.grid.data.Objects([{key: "name"}, {key: "city"},{key: "state"},{key: "zip"}], null);
// Process the response from the customers web service function handleResponse(data, ioArgs){ dojo.require("dojox.grid.DataGrid"); dojo.require("dojox.xml.DomParser"); HOW do I load data into the model here? //alert(data); var jsonStore = dojox.xml.DomParser.parse(data);
// set the model object with the returned customers list to be displayed in grid
model.setData(jsonStore);
You need to put and items argument with the list of all your data see here
精彩评论