!function(e,r){"use strict";"function"==typeof define&&define.amd?define(["jquery","./grid.base","./jsonxml"],function(t){return r(t,e)}):"object"==typeof module&&module.exports?module.exports=function(t,e){return t||(t=window),void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(t)),require("./grid.base"),require("./jsonxml"),r(e,t),e}:r(jQuery,e)}("undefined"!=typeof window?window:this,function(l,r){"use strict";var d=l.jgrid;l.jgrid.extend({jqGridImport:function(i){return i=l.extend({imptype:"xml",impstring:"",impurl:"",mtype:"GET",impData:{},xmlGrid:{config:"roots>grid",data:"roots>rows"},jsonGrid:{config:"grid",data:"data"},ajaxOptions:{}},i||{}),this.each(function(){var t,p=this,e=function(t,e){var r,i,o,s,n=l(e.xmlGrid.config,t)[0],a=l(e.xmlGrid.data,t)[0];if(xmlJsonClass.xml2json){for(o in r=xmlJsonClass.xml2json(n," "),r=l.parseJSON(r))r.hasOwnProperty(o)&&(i=r[o]);void 0!==i&&(a?(s=r.grid.datatype,r.grid.datatype="xmlstring",r.grid.datastr=t,l(p).jqGrid(i).jqGrid("setGridParam",{datatype:s})):l(p).jqGrid(i))}else(null!=d.defaults&&l.isFunction(d.defaults.fatalError)?d.defaults.fatalError:alert)("xml2json or parse are not present")},r=function(t,e){if(t&&"string"==typeof t){var r,i=l.parseJSON(t),o=i[e.jsonGrid.config],s=i[e.jsonGrid.data];s?(r=o.datatype,o.datatype="jsonstring",o.datastr=s,l(p).jqGrid(o).jqGrid("setGridParam",{datatype:r})):l(p).jqGrid(o)}};switch(i.imptype){case"xml":l.ajax(l.extend({url:i.impurl,type:i.mtype,data:i.impData,dataType:"xml",context:i,complete:function(t){!(t.status<300||304===t.status)||0===t.status&&4===t.readyState||(e(t.responseXML,this),l(p).triggerHandler("jqGridImportComplete",[t,this]),l.isFunction(this.importComplete)&&this.importComplete(t))}},i.ajaxOptions));break;case"xmlstring":i.impstring&&"string"==typeof i.impstring&&(t=l.parseXML(i.impstring))&&(e(t,i),l(p).triggerHandler("jqGridImportComplete",[t,i]),l.isFunction(i.importComplete)&&i.importComplete(t),i.impstring=null);break;case"json":l.ajax(l.extend({url:i.impurl,type:i.mtype,data:i.impData,dataType:"json",context:i,complete:function(t){try{!(t.status<300||304===t.status)||0===t.status&&4===t.readyState||(r(t.responseText,this),l(p).triggerHandler("jqGridImportComplete",[t,this]),l.isFunction(this.importComplete)&&this.importComplete(t))}catch(t){}}},i.ajaxOptions));break;case"jsonstring":i.impstring&&"string"==typeof i.impstring&&(r(i.impstring,i),l(p).triggerHandler("jqGridImportComplete",[i.impstring,i]),l.isFunction(i.importComplete)&&i.importComplete(i.impstring),i.impstring=null)}})},jqGridExport:function(r){r=l.extend({exptype:"xmlstring",root:"grid",ident:"\t"},r||{});var i=null;return this.each(function(){if(this.grid){var t,e=l.extend(!0,{},l(this).jqGrid("getGridParam"));if(e.rownumbers&&(e.colNames.splice(0,1),e.colModel.splice(0,1)),e.multiselect&&(e.colNames.splice(0,1),e.colModel.splice(0,1)),e.subGrid&&(e.colNames.splice(0,1),e.colModel.splice(0,1)),e.knv=null,e.treeGrid)for(t in e.treeReader)e.treeReader.hasOwnProperty(t)&&(e.colNames.splice(e.colNames.length-1),e.colModel.splice(e.colModel.length-1));switch(r.exptype){case"xmlstring":i="<"+r.root+">"+xmlJsonClass.json2xml(e,r.ident)+"";break;case"jsonstring":i="{"+xmlJsonClass.toJson(e,r.root,r.ident,!1)+"}",void 0!==e.postData.filters&&(i=(i=i.replace(/filters":"/,'filters":')).replace(/\}\]\}"/,"}]}"))}}}),i},excelExport:function(e){return e=l.extend({exptype:"remote",url:null,oper:"oper",tag:"excel",exportOptions:{}},e||{}),this.each(function(){var t;this.grid&&"remote"===e.exptype&&((t=l.extend({},this.p.postData,e.exportOptions))[e.oper]=e.tag,r.location=e.url+(null!=e.url&&0<=e.url.indexOf("?")?"&":"?")+l.param(t))})}})}); //# sourceMappingURL=grid.import.js.map