I am trying to create a jqGrid using the result of a jQuery selection from an XML string.
I have a page that loads a large XML response (SOAP). I would like to save the initial response and dynamically use portions of the response in different jqGrid tables. When I search for the portion of the XML using jQuery, I get the correct portion of the response for the table, but I am stuck at the point of building a table from the jQuery result object. The loatTabTrip
function below works fine with a raw string of XML given as the travelXml
argument, but it does not work with the jQuery result. (So if I could get the jQuery object as a string of XML, that would work; or if jqGrid would accept the object.)
Any ideas?
<Travel>
<TravelKey>2010020029A</TravelKey>
<TravelCategoryCode>AIR</TravelCategoryCode>
<Trips>
<Trip>
<AircraftTrip>
<TripKey>
<TripId>50</TripId>
<TravelKey>2010020029A</TravelKey>
</TripKey>
<AssignedTravelTaskReferences>
<AssignedTravelTaskReference>
<TaskId>80203</TaskId>
<TravelKey>2010020029A</TravelKey>
</AssignedTravelTaskReference>
</AssignedTravelTaskReferences>
<TripTravelId>6JG79822S</TripTravelId>
<Aircraft>
<AircraftModelCode>KC135R</AircraftModelCode>
<SerialNumber>83104038</SerialNumber>
</Aircraft>
<Route>...</Route>
</AircraftTrip>
</Trip>
<Trip>...</Trip>
</Travel>
function loadTabTrip(travelXml){
jQuery("#travelTripsTable").jqGrid({
datatype:'xmlstring',
datastr: travelXml,
colNames:["ID","Aircraft"],
colModel:[
{name:"id",index:"id", width:380, align:"right",xmlmap:">TripKey>TripId"},
{name:"type",index:"type", width:80, xmlmap:">Aircraft>AircraftModelCode"}
],
xmlReader: {
root : "Travel>Trips",
row: ">Trip>AircraftTrip",
repeatitems: false,
id: ">TripKey>TripId"
}
});
}