以下のコードが役立ちます:
/**
* This method is called on save button click by passing the grid object as a parameter
*/
saveGridModifiedRecords = function (yourGrid) {
Ext.getCmp("yourGridId").body.mask('Saving Record Please Wait...');
var modifiedRecords = yourGrid.getStore().getModifiedRecords();
var CIxml = StringToXML("<Root/>");
for (var i = 0; i < modifiedRecords.length; i++) {
var fields = modifiedRecords[i]; // Gives you each edited record
var cuurElem = CIxml.createElement("I");
cuurElem.setAttribute("name", fields.get("name")); // Here name is the dataindex of a field
cuurElem.setAttribute("category", fields.get("category")); // Here category is the dataindex of a field
CIxml.documentElement.appendChild(cuurElem);
}
Use an AJAX call to send this xml with modified records to server.
Ext.Ajax.request({
url : 'yourWebServiceURL/parameter1/parametr2',
method : 'POST',
timeout : 120000,
params : {
'strIPXML' : CIxml.xml
}, // We are passing xml as a string here by using .xml
success : function (response) {
// Extract response.resposeXML for a xml format of response else response.responseText for a string.
Ext.getCmp("yourGridId").body.unmask();
alert('In success');
},
failure : function (response) {
alert('In Failure');
if (Ext.getCmp("yourGridId")) {
Ext.getCmp("yourGridId").body.unmask();
}
}
});
}
function StringToXML(oString) {
//code for IE
if (window.ActiveXObject) {
var oXML = new ActiveXObject("Microsoft.XMLDOM"); oXML.loadXML(oString);
return oXML;
}
// code for Chrome, Safari, Firefox, Opera, etc.
else {
return (new DOMParser()).parseFromString(oString, "text/xml");
}
}