All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.openmonitor.jui.dest.grid.grid.view.js Maven / Gradle / Ivy

Go to download

一个简单易用的接口开放平台,平台封装了常用的参数校验、结果返回等功能,开发者只需实现业务代码即可。https://gitee.com/durcframework/easyopen

There is a newer version: 1.16.20
Show newest version
(function(){JUI.Class("GridView",{init:function(a){this._super(a);this.grid=a;var b=a.id;this.idField=this.opt("idField")||("idField_"+b);this.checkboxTrigger="checkboxChange";this.radioTrigger="radioChange";this.selectCache=a.getSelectCache()},refresh:function(){var a=this.grid.data;this.createHead();this.refreshBody(a);this.createFoot();this.refreshPage(a);this.grid.fire("RefreshSuccess",{$table:this.$tpl,grid:this.grid,data:a})},createBodyTd:function(a,c,d){var b=$("");this.formatTd(a,c,d,b);return b},formatTd:function(a,e,g,d){var b=this;var c=e[g.field];var f=g.align;if(f){d.attr("align",f)}if(g.hidden===true){d.hide()}if(g.styler){d.attr("style",g.styler(c,e,a))}if(b.opt("nowrap")){d.css({whiteSpace:"nowrap"})}else{d.css({whiteSpace:"normal",wordWrap:"break-word"})}if(g.checkbox){b.buildSelections(d,a,e,g);return}if(g.formatter){c=g.formatter(c,e,a,d)}d.on("click",function(h){b.vCellClick(g,e,h,a)}).on("dblclick",function(h){b.vCellDblClick(g,e,h,a)});d.html(c)},createBodyTr:function(a,d){var c=$("");var b=this;c.on("click",function(f){b.vRowClick(a,d,f)}).on("dblclick",function(f){b.vRowDblClick(a,d,f)});return c},refreshBody:function(f){var l=f[this.opt("serverRowsName")];var d=this.opt("columns")[0];var e=this.$tpl.find("tbody");if(l&&l.length){e.html("");for(var i=0,h=l.length;i'+this.grid.opts.emptyDataMsg+"")}},appendRowNumberColumn:function(d,b){if(this.grid.opts.rownumbers){var c=this.createBodyTd(0,{rownum:d+1},{field:"rownum"});var a=parseInt(this.opt("rowNumberTdWidth"));c.width(a).css("background-color","#fff");b.append(c)}},createHead:function(){if(!this.headInited){var d=this.opt("columns")[0];var e=this.createHeadTr();if(this.grid.opts.rownumbers){var b=this.createHeadTh(0,{title:this.grid.opts.rownumberTitle});b.addClass("juigrid-rownumber-head-th");e.append(b)}for(var a=0,c=d.length;a");return b},createHeadTh:function(a,c){var b=$("");b.html(c.title);this.formatHeadTd(c,b);return b},formatHeadTd:function(e,b){var c=this;var d=e.halign||e.align;if(d){b.css("text-align",d)}if(e.hidden===true){b.hide()}if(e.width){b.width(parseInt(e.width))}if(e.checkbox){if(c.isMultiSelect()){var a=this.createCheckAll();b.html(a).css("text-align","center")}b.width(c.opt("checkTdWidth"))}if(e.sortable){this.initSortBtn(e,b)}},initSortBtn:function(f,b){var d=this;var c=d.sortOrder;var e=f.field;var a=$(this).find("span");if(a.length==0){a=$("");b.append(a)}b.css({cursor:"pointer"}).click(function(){b.siblings().find("span").html("");if(this.currentSortOrder=="ASC"){a.html("▼");this.currentSortOrder="DESC"}else{a.html("▲");this.currentSortOrder="ASC"}d.grid.sort(e,this.currentSortOrder)})},createCheckAll:function(){var a=this;a.$checkAll=$('').bind("doClick",function(f,c){var b=c?a.getUnCheckCheckbox():a.getCheckedCheckbox();var d=c?"CheckAll":"UncheckAll";b.each(function(){this.checked=c;$(this).trigger(a.checkboxTrigger)});a.grid.fire(d,{rows:a.grid.getRows(),$target:a.$checkAll,$checkboxs:b})}).click(function(){$(this).trigger("doClick",[this.checked])}).css("cursor","pointer");return a.$checkAll},createFoot:function(){if(!this.footInited){var b=this.$tpl.find("tfoot");var c=$("");var e=this.getColCount();var d=$('');var a=$('
    ');if(this.grid.opts.pagination){a.append(this.buildPageSizeSelect());a.append(this.buildFirst());a.append(this.buildPrev());a.append(this.buildNext());a.append(this.buildLast());a.append(this.buildPageMsg());d.append(a);c.append(d)}b.append(c);this.footInited=true}},getColCount:function(){if(!this._colspan){var a=this.opt("columns")[0].length;this._colspan=this.grid.opts.rownumbers?a+1:a}return this._colspan},buildPageSizeSelect:function(){var d=[];var e=this.grid.opts.pageSelectStyle;d.push('");this.$select=$(d.join(""));this.$select.change(function(){f.pageSize=parseInt(this.value);f.onChange()});return $("
  • ").append(this.$select)},buildFirst:function(){var a=this.getPage();this.$first=$('
  • 首页
  • ').click(function(){a.first()});return this.$first},buildPrev:function(){var a=this.getPage();this.$prev=$('
  • 上一页
  • ').click(function(){a.pre()});return this.$prev},buildNext:function(){var a=this.getPage();this.$next=$('
  • 下一页
  • ').click(function(){a.next()});return this.$next},buildLast:function(){var a=this.getPage();this.$last=$('
  • 尾页
  • ').click(function(){a.last()});return this.$last},buildPageMsg:function(){this.$pageInfo=$('
    ');var a=$("
  • ");a.append(this.$pageInfo);return a},refreshPage:function(){if(this.grid.opts.pagination){var a=this.getPage();this.$pageInfo.html("第"+a.pageIndex+"/"+a.pageCount+"页,共"+a.total+"条数据");this.$first.attr("class",a.canFirst()?"":"disabled");this.$prev.attr("class",a.canPre()?"":"disabled");this.$next.attr("class",a.canNext()?"":"disabled");this.$last.attr("class",a.canLast()?"":"disabled");this.$select.val(a.pageSize)}},getPageList:function(){var f=this.opt("pageList");var a=parseInt(this.opt("pageSize"))||10;f.push(a);var g={};for(var e=0,d=f.length;e").click(function(k){k.stopPropagation();h.call(e,$(this),f,j)}).css("cursor","pointer");this.bindCheckState(b);this.bindCheckboxEvent(b,f,j);a.html(b).css("text-align","center")},bindCheckState:function(b){if(this.isSelectCache()){var c=b.val();var a=this.grid.isInCache(c);b.prop("checked",a)}},bindCheckboxEvent:function(b,a,e){var c=this;var d={index:a,row:e,$target:b};b.bind(c.checkboxTrigger,function(){var h=this.checked;var g=h?"Check":"Uncheck";var f=$(this);c.setCheckboxCache(f,e);if(c.opt("checkboxDeepTrigger")){c.grid.fire(g,d)}});b.bind(c.radioTrigger,function(){var i=this.checked;var g=i?"Select":"UnSelect";var f=$(this);var h=f.parents("tr");c.setRadioCache(f,e);c.grid.fire(g,d)})},setCheckboxCache:function(a,b){if(this.isSelectCache()){this.getSelectCache()[a.val()]=a.prop("checked")?b:false}},setRadioCache:function(a,b){if(this.isSelectCache()){this.grid.resetSelectCache();this.getSelectCache()[a.val()]=a.prop("checked")?b:false}},getSelectCache:function(){return this.grid.getSelectCache()},isSelectCache:function(){return this.grid.isSelectCache()},radioClickHandler:function(a,b,c){a.trigger(this.radioTrigger)},checkboxClickHandler:function(b,a,c){b.trigger(this.checkboxTrigger)},isCheckedAll:function(){var a=this.getCheckedCheckbox().length;var b=this.grid.getRows().length;return b==a},checkAll:function(){var b=this;if(this.isMultiSelect()){var a=true;this.$checkAll.prop("checked",a).trigger("doClick",[a])}},uncheckAll:function(){var c=this;if(this.isMultiSelect()){var b=false;this.$checkAll.prop("checked",b).trigger("doClick",[b])}else{var a=this.getCheckedCheckbox();a.each(function(){this.checked=false;$(this).trigger(c.getTriggerName())})}},selectRow:function(b){if(this.isSingleSelect()){var a=this.getAllCheckbox().eq(b);console.log(a);var c=a.prop("checked");if(!c){a.prop("checked",!c);a.trigger(this.radioTrigger)}}},unselectRow:function(b){if(this.isSingleSelect()){var a=this.getAllCheckbox().eq(b);var c=a.prop("checked");if(c){a.prop("checked",!c);a.trigger(this.getTriggerName())}}},checkRow:function(a){if(this.isMultiSelect()){var b=this.getAllCheckbox().eq(a);var c=b.prop("checked");if(!c){b.prop("checked",true);b.trigger(this.getTriggerName())}}},uncheckRow:function(a){if(this.isMultiSelect()){var b=this.getAllCheckbox().eq(a);var c=b.prop("checked");if(c){b.prop("checked",false);b.trigger(this.getTriggerName())}}},selectRecord:function(c,a){var b=this.getCheckboxByIdValue(c);var d=b.prop("checked");if(!d){b.prop("checked",true);b.trigger(this.getTriggerName())}},vCellClick:function(g,f,b,a){var d=f[g.field];var c={index:a,head:g,value:d,row:f,target:b.target};this.grid.fire("ClickCell",c)},vCellDblClick:function(g,f,b,a){var d=f[g.field];var c={index:a,head:g,value:d,row:f,target:b.target};this.grid.fire("DblClickCell",c)},vRowClick:function(a,d,b){var c={index:a,row:d,target:b.target};this.grid.fire("ClickRow",c)},vRowDblClick:function(a,d,b){var c={index:a,row:d,target:b.target};this.grid.fire("DblClickRow",c)},getTriggerName:function(){return this.isSingleSelect()?this.radioTrigger:this.checkboxTrigger},isMultiSelect:function(){return !this.isSingleSelect()},isSingleSelect:function(){return this.opt("singleSelect")},getCheckType:function(){if(!this.checkType){this.checkType=this.isSingleSelect()?"radio":"checkbox"}return this.checkType},getCheckedCheckbox:function(){return this.$wraper.find('input[class="jui-check"]:checked')},getAllCheckbox:function(){return this.$wraper.find('input[class="jui-check"]')},getUnCheckCheckbox:function(){return this.$wraper.find('input[class="jui-check"]:not(:checked)')},getCheckboxByIdValue:function(a){return this.$wraper.find('input[value="'+a+'"]')},getCheckboxByIndex:function(a){return this.$wraper.find('input[data-index="'+a+'"]')},getCheckedIndex:function(){var a=this.getCheckedCheckbox();var b=[];a.each(function(){b.push(parseInt($(this).attr("data-index")))});return b},getTemplate:function(){var b=$("
    ");var a=JUIConfig.Grid;var c=a.tableCss;b.addClass(c);if(this.opt("striped")){b.addClass(a.tableStripedCss)}if(this.opt("hover")){b.addClass(a.tableHoverCss)}if(this.opt("bordered")){b.addClass(a.tableBrderedCss)}b.css({width:this.grid.getTableWidth()});return b}},JUI.View)})();




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy