123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- (function () {
- var BSTable = function (bstableId, url, columns) {
- this.btInstance = null;
- this.bstableId = bstableId;
- this.url = Feng.ctxPath + url;
- this.method = "post";
- this.paginationType = "server";
- this.toolbarId = bstableId + "Toolbar";
- this.columns = columns;
- this.height = 600;
- this.data = {};
- this.singleSelect = true;
- this.queryParams = {};
- this.onLoadSuccess = function(){};
- this.onDblClickRow = function () {};
- this.headerStyle = function(){};
- this.detailView = false;
- this.rowStyle=function () {
- return {
- }
- };
- };
- BSTable.prototype = {
-
- init: function () {
- var tableId = this.bstableId;
- var me = this;
- this.btInstance =
- $('#' + tableId).bootstrapTable({
- contentType: "application/x-www-form-urlencoded",
- url: this.url,
- method: this.method,
- ajaxOptions: {
- data: this.data
- },
- toolbar: "#" + this.toolbarId,
- striped: true,
- cache: false,
- pagination: true,
- sortable: true,
- sortOrder: "desc",
- pageNumber: 1,
- pageSize: 10,
- pageList: [10,20,50,100],
- showJumpto:true,
- queryParamsType: 'limit',
- queryParams: function (param) {
- return $.extend(me.queryParams, param);
- },
- sidePagination: this.paginationType,
- search: false,
- strictSearch: true,
- showColumns: true,
- showRefresh: true,
- singleSelect:this.singleSelect,
- minimumCountColumns: 2,
- clickToSelect: true,
- searchOnEnterKey: true,
- columns: this.columns,
- height: this.height,
- detailView:this.detailView,
- icons: {
- refresh: 'glyphicon-repeat',
- toggle: 'glyphicon-list-alt',
- columns: 'glyphicon-list'
- },
- iconSize: 'sm',
- onLoadSuccess : this.onLoadSuccess,
- onDblClickRow : this.onDblClickRow,
- rowStyle:this.rowStyle,
- headerStyle:this.headerStyle,
- classes: "table table-bordered table-hover table-sm",
- onPostBody: function(){
- $("td.uitd_showTip").bind("mouseover", function(){
- var htm = $(this).html();
- if (htm!=null && htm.length>1){
- $(this).webuiPopover({content:htm,trigger:'hover'}).webuiPopover('show');
- }
- });
- }
- });
- return this;
- },
-
- setQueryParams: function (param) {
- this.queryParams = param;
- },
-
- setPaginationType: function (type) {
- this.paginationType = type;
- },
- setOnLoadSuccess: function (fun) {
- this.onLoadSuccess = fun;
- },
- setOnDblClickRow :function(fun){
- this.onDblClickRow = fun;
- },
- setDetailView : function(b){
- this.detailView = b;
- },
- setRowStyle:function(fun){
- this.rowStyle=fun;
- },
- setHeight : function(h){
- this.height = h;
- },
- setSingleSelect:function(b){
- this.singleSelect = b;
- },
-
- set: function (key, value) {
- if (typeof key == "object") {
- for (var i in key) {
- if (typeof i == "function")
- continue;
- this.data[i] = key[i];
- }
- } else {
- this.data[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
- }
- return this;
- },
-
- setData: function (data) {
- this.data = data;
- return this;
- },
-
- clear: function () {
- this.data = {};
- return this;
- },
- setHeaderStyle:function(style){
- this.headerStyle = style;
- },
-
- refresh: function (parms) {
- if (typeof parms != "undefined") {
- this.btInstance.bootstrapTable('refresh', parms);
- } else {
- this.btInstance.bootstrapTable('refresh');
- }
- }
- };
- window.BSTable = BSTable;
- }());
|