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