(function(n,t,i){function e(n,i){var u=t(n);u.data(o,this);this._container=u;this.data=[];this.total=0;this.fields=[];this._editingRow=null;this._sortField=null;this._sortOrder=r;this._firstDisplayingPage=1;this._init(i);this.render()}var o="JSGrid",f="JSGridItem",s="JSGridEditRow",r="asc",v="desc",y="{first}",p="{pages}",w="{prev}",b="{next}",k="{last}",d="{pageIndex}",g="{pageCount}",nt="{itemCount}",tt="javascript:void(0);",u=function(n,i){return t.isFunction(n)?n.apply(i,t.makeArray(arguments).slice(2)):n},it=function(n){var i=t.Deferred();return n&&n.then?n.then(function(){i.resolve.apply(i,arguments)},function(){i.reject.apply(i,arguments)}):i.resolve(n),i.promise()},h={loadData:t.noop,insertItem:t.noop,updateItem:t.noop,deleteItem:t.noop};e.prototype={width:"auto",height:"auto",updateOnResize:!0,rowClass:t.noop,rowRenderer:null,rowClick:function(n){this.editing&&this.editItem(t(n.event.target).closest("tr"))},rowDoubleClick:t.noop,rowMouseDown:t.noop,rowMouseUp:t.noop,rowMouseUut:t.noop,noDataContent:"Not found",noDataRowClass:"jsgrid-nodata-row",heading:!0,headerRowRenderer:null,headerRowClass:"jsgrid-header-row",headerCellClass:"jsgrid-header-cell",filtering:!1,filterRowRenderer:null,filterRowClass:"jsgrid-filter-row",inserting:!1,insertRowRenderer:null,insertRowClass:"jsgrid-insert-row",editing:!1,editRowRenderer:null,editRowClass:"jsgrid-edit-row",confirmDeleting:!0,deleteConfirm:"Are you sure?",selecting:!0,selectedRowClass:"jsgrid-selected-row",oddRowClass:"jsgrid-row",evenRowClass:"jsgrid-alt-row",cellClass:"jsgrid-cell",sorting:!1,sortableClass:"jsgrid-header-sortable",sortAscClass:"jsgrid-header-sort jsgrid-header-sort-asc",sortDescClass:"jsgrid-header-sort jsgrid-header-sort-desc",paging:!1,pagerContainer:null,pageIndex:1,pageSize:20,pageButtonCount:15,pagerFormat:"{Total} {itemCount} {Pen} {first} {prev} {pages} {next} {last} {Numth} {pageIndex} {Page} {Total} {pageCount} {Page}",pagePrevText:"Prev",pageNextText:"Next",pageFirstText:"First",pageLastText:"Last",pageNavigatorNextText:"...",pageNavigatorPrevText:"...",pagerContainerClass:"jsgrid-pager-container",pagerClass:"jsgrid-pager",pagerNavButtonClass:"jsgrid-pager-nav-button",pagerNavButtonInactiveClass:"jsgrid-pager-nav-inactive-button",pageClass:"jsgrid-pager-page",currentPageClass:"jsgrid-pager-current-page",customLoading:!1,pageLoading:!1,autoload:!1,controller:h,loadIndication:!0,loadIndicationDelay:500,loadMessage:"Please, wait...",loadShading:!0,invalidMessage:"Invalid data entered!",invalidNotify:function(n){var i=t.map(n.errors,function(n){return n.message||null});showMsg([this.invalidMessage].concat(i).join("
"),"info")},onInit:t.noop,onRefreshing:t.noop,onRefreshed:t.noop,onPageChanged:t.noop,onItemDeleting:t.noop,onItemDeleted:t.noop,onItemInserting:t.noop,onItemInserted:t.noop,onItemEditing:t.noop,onItemUpdating:t.noop,onItemUpdated:t.noop,onItemInvalid:t.noop,onDataLoading:t.noop,onDataLoaded:t.noop,onOptionChanging:t.noop,onOptionChanged:t.noop,onError:t.noop,invalidClass:"jsgrid-invalid",containerClass:"jsgrid",tableClass:"jsgrid-table",gridHeaderClass:"jsgrid-grid-header",gridBodyClass:"jsgrid-grid-body",_init:function(n){t.extend(this,n);this._initLoadStrategy();this._initController();this._initFields();this._attachWindowLoadResize();this._attachWindowResizeCallback();this._callEventHandler(this.onInit);this.dfheight||(this.dfheight=this.height)},loadStrategy:function(){return this.pageLoading?new jsGrid.loadStrategies.PageLoadingStrategy(this):new jsGrid.loadStrategies.DirectLoadingStrategy(this)},_initLoadStrategy:function(){this._loadStrategy=u(this.loadStrategy,this)},_initController:function(){this._controller=t.extend({},h,u(this.controller,this))},renderTemplate:function(n,t,r){args=[];for(var f in r)args.push(r[f]);return args.unshift(n,t),n=u.apply(null,args),n===i||n===null?"":n},loadIndicator:function(n){return new jsGrid.LoadIndicator(n)},validation:function(n){return jsGrid.Validation&&new jsGrid.Validation(n)},_initFields:function(){var n=this;n.fields=t.map(n.fields,function(i){if(t.isPlainObject(i)){var r=i.type&&jsGrid.fields[i.type]||jsGrid.Field;i=new r(i)}return i._grid=n,i})},_attachWindowLoadResize:function(){t(n).on("load",t.proxy(this._refreshSize,this))},_attachWindowResizeCallback:function(){if(this.updateOnResize)t(n).on("resize",t.proxy(this._refreshSize,this))},_detachWindowResizeCallback:function(){t(n).off("resize",this._refreshSize)},option:function(n,t){var i,r;if(arguments.length===1)return this[n];i={option:n,oldValue:this[n],newValue:t};this._callEventHandler(this.onOptionChanging,i);this._handleOptionChange(i.option,i.newValue);r={option:i.option,value:i.newValue};this._callEventHandler(this.onOptionChanged,r)},fieldOption:function(n,t,i){if(n=this._normalizeField(n),arguments.length===2)return n[t];n[t]=i;this._renderGrid()},_handleOptionChange:function(n,t){this[n]=t;switch(n){case"width":case"height":this._refreshSize();break;case"rowClass":case"rowRenderer":case"rowClick":case"rowDoubleClick":case"rowMouseDown":case"rowMouseUp":case"rowMouseUut":case"noDataRowClass":case"noDataContent":case"selecting":case"selectedRowClass":case"oddRowClass":case"evenRowClass":this._refreshContent();break;case"pageButtonCount":case"pagerFormat":case"pagePrevText":case"pageNextText":case"pageFirstText":case"pageLastText":case"pageNavigatorNextText":case"pageNavigatorPrevText":case"pagerClass":case"pagerNavButtonClass":case"pageClass":case"currentPageClass":case"pagerRenderer":this._refreshPager();break;case"fields":this._initFields();this.render();break;case"data":case"editing":case"heading":case"filtering":case"inserting":case"paging":this.refresh();break;case"loadStrategy":case"pageLoading":this._initLoadStrategy();this.search();break;case"pageIndex":this.openPage(t);break;case"pageSize":this.refresh();this.search();break;case"editRowRenderer":case"editRowClass":this.cancelEdit();break;case"updateOnResize":this._detachWindowResizeCallback();this._attachWindowResizeCallback();break;case"invalidNotify":case"invalidMessage":break;default:this.render()}},destroy:function(){this._detachWindowResizeCallback();this._clear();this._container.removeData(o)},render:function(){return this._renderGrid(),this.autoload?this.loadData():t.Deferred().resolve().promise()},_renderGrid:function(){this._clear();this._container.addClass(this.containerClass).css("position","relative").append(this._createHeader()).append(this._createBody());this._pagerContainer=this._createPagerContainer();this._loadIndicator=this._createLoadIndicator();this._validation=this._createValidation();this.refresh()},_createLoadIndicator:function(){return u(this.loadIndicator,this,{message:this.loadMessage,shading:this.loadShading,container:this._container})},_createValidation:function(){return u(this.validation,this)},_clear:function(){this.cancelEdit();clearTimeout(this._loadingTimer);this._pagerContainer&&this._pagerContainer.empty();this._container.empty().css({position:"",width:"",height:""})},_createHeader:function(){var n=this._headerRow=this._createHeaderRow(),i=this._filterRow=this._createFilterRow(),r=this._insertRow=this._createInsertRow(),u=this._headerGrid=t("
",i,"headercss",this.headerCellClass).append(this.renderTemplate(i.headerTemplate,i));if(i.title&&u.attr("data-i18n",i.title),u.appendTo(n),this.sorting&&i.sorting)u.addClass(this.sortableClass).on("click",t.proxy(function(){typeof this.headerClick=="function"&&this.headerClick();this.sort(r)},this))}),n},_prepareCell:function(n,i,r,u){return t(n).css("width",i.width).addClass(u||this.cellClass).addClass(r&&i[r]||i.css).addClass(i.align?"jsgrid-align-"+i.align:"")},_createFilterRow:function(){if(t.isFunction(this.filterRowRenderer))return t(this.renderTemplate(this.filterRowRenderer,this));var n=t(" | ||
---|---|---|
",t,"filtercss").append(this.renderTemplate(t.filterTemplate,t)).appendTo(n)}),n},_createInsertRow:function(){if(t.isFunction(this.insertRowRenderer))return t(this.renderTemplate(this.insertRowRenderer,this));var n=t(" | ||
",t,"insertcss").append(this.renderTemplate(t.insertTemplate,t)).appendTo(n)}),n},_callEventHandler:function(n,i){return n.call(this,t.extend(i,{grid:this})),i},reset:function(){return this._resetSorting(),this._resetPager(),this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1;this._setPage(1)},_resetSorting:function(){this._sortField=null;this._sortOrder=r;this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing);this.cancelEdit();this._refreshHeading();this._refreshFiltering();this._refreshInserting();this._refreshContent();this._refreshPager();this._refreshSize();this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var t=this._content,i,r,n,u;if(t.empty(),!this.data.length)return t.append(this._createNoDataRow()),this;for(i=this._loadStrategy.firstDisplayIndex(),r=this._loadStrategy.lastDisplayIndex(),n=i;n").addClass(this.cellClass).attr("colspan",n).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(n,i){var r;t.isFunction(this.rowRenderer)?r=this.renderTemplate(this.rowRenderer,this,{item:n,itemIndex:i}):(r=t(" | ").append(this.renderTemplate(i.itemTemplate||u,i,f)),this._prepareCell(r,i)},_getItemFieldValue:function(n,t){for(var r=t.name.split("."),i=n[r.shift()];i&&r.length;)i=i[r.shift()];return i},_setItemFieldValue:function(n,t,i){for(var r=t.name.split("."),f=n,u=r[0];f&&r.length;)n=f,u=r.shift(),f=n[u];if(!f)while(r.length)n=n[u]={},u=r.shift();n[u]=i},sort:function(n,i){return t.isPlainObject(n)&&(i=n.order,n=n.field),this._clearSortingCss(),this._setSortingParams(n,i),this._setSortingCss(),this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDescClass)},_setSortingParams:function(n,t){n=this._normalizeField(n);t=t||(this._sortField===n?this._reversedSortOrder(this._sortOrder):r);this._sortField=n;this._sortOrder=t},_normalizeField:function(n){return t.isNumeric(n)?this.fields[n]:typeof n=="string"?t.grep(this.fields,function(t){return t.name===n})[0]:n},_reversedSortOrder:function(n){return n===r?v:r},_setSortingCss:function(){var n=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(n).addClass(this._sortOrder===r?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(n){return t.inArray(n,t.grep(this.fields,function(n){return n.visible}))},_sortData:function(){var t=this._sortFactor(),n=this._sortField;n&&this.data.sort(function(i,r){return t*n.sortingFunc(i[n.name],r[n.name])})},_sortFactor:function(){return this._sortOrder===r?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var n=this._itemsCount(),t=this.pageSize;return Math.floor(n/t)+(n%t?1:0)},_refreshPager:function(){var n=this._pagerContainer,t;n.empty();this.paging&&n.append(this._createPager());t=this.paging&&this._pagesCount()>1;t||n.find("#PerPageNum").val("");n.toggle(t);refreshLang()},_createPager:function(){var n;return n=t.isFunction(this.pagerRenderer)?t(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):t(" | ").append(this._createPagerByFormat()).append([' <\/span>',t("",{id:"PerPageNum","class":"form-control w50",value:this.pageSize,keyup:function(){for(var t=this.value,i="",n=0;n |