grid.tbltogrid.js 1.7 KB

12
  1. !function(e,i){"use strict";"function"==typeof define&&define.amd?define(["jquery","./grid.base"],function(t){return i(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"),i(e,t)}:i(jQuery,e)}("undefined"!=typeof window?window:this,function(m,t){"use strict";return t.tableToGrid=function(t,p){m(t).each(function(){var t,e,i,n,d,r,h,o,s=m(this),l=[],u=[],c=[],a=[],f=[];if(!this.grid){for(s.width("99%"),t=s.width(),e=m("tr td:first-child input[type=checkbox]:first",s),i=m("tr td:first-child input[type=radio]:first",s),d=!(n=0<e.length)&&0<i.length,r=n||d,m("th",s).each(function(){0===l.length&&r?(l.push({name:"__selection__",index:"__selection__",width:0,hidden:!0}),u.push("__selection__")):(l.push({name:m(this).attr("id")||m.trim(m.jgrid.stripHtml(m(this).html())).split(" ").join("_"),index:m(this).attr("id")||m.trim(m.jgrid.stripHtml(m(this).html())).split(" ").join("_"),width:m(this).width()||150}),u.push(m(this).html()))}),m("tbody > tr",s).each(function(){var i={},n=0;m("td",m(this)).each(function(){if(0===n&&r){var t=m("input",m(this)),e=t.attr("value");a.push(e||c.length),t.is(":checked")&&f.push(e),i[l[n].name]=t.attr("value")}else i[l[n].name]=m(this).html();n++}),0<n&&c.push(i)}),s.empty(),s.jqGrid(m.extend({datatype:"local",width:t,colNames:u,colModel:l,multiselect:n},p||{})),h=0;h<c.length;h++)o=null,0<a.length&&(o=a[h])&&o.replace&&(o=encodeURIComponent(o).replace(/[.\-%]/g,"_")),null===o&&(o=m.jgrid.randId()),s.jqGrid("addRowData",o,c[h]);for(h=0;h<f.length;h++)s.jqGrid("setSelection",f[h])}})},t.tableToGrid});
  2. //# sourceMappingURL=grid.tbltogrid.js.map