浏览代码

Merge pull request #584 from djhvscf/master

Added show/hide row
文翼 10 年之前
父节点
当前提交
9cd639f039
共有 1 个文件被更改,包括 19 次插入3 次删除
  1. 19 3
      src/bootstrap-table.js

+ 19 - 3
src/bootstrap-table.js

@@ -1499,6 +1499,14 @@
             }
         }
     };
+	
+    BootstrapTable.prototype.toggleRow = function (index, visible) {
+	if (index === -1) {
+	   return;
+	}
+		
+	this.$selectItem.filter(sprintf('[data-index="%s"]', index)).parents('tr')[visible ? 'show' : 'hide']();
+     };
 
     // PUBLIC FUNCTION DEFINITION
     // =======================
@@ -1627,6 +1635,14 @@
         $.extend(this.data[params.index], params.row);
         this.initBody(true);
     };
+	
+    BootstrapTable.prototype.showRow = function (index) {
+        this.toggleRow(index, true);
+    };
+
+    BootstrapTable.prototype.hideRow = function (index) {
+        this.toggleRow(index, false);
+    };
 
     BootstrapTable.prototype.mergeCells = function (options) {
         var row = options.index,
@@ -1770,7 +1786,7 @@
     BootstrapTable.prototype.hideColumn = function (field) {
         this.toggleColumn(getFieldIndex(this.options.columns, field), false, true);
     };
-
+	
     BootstrapTable.prototype.filterBy = function (columns) {
         this.filterColumns = $.isEmptyObject(columns) ? {} : columns;
         this.options.pageNumber = 1;
@@ -1814,7 +1830,7 @@
         this.initHeader();
         this.initBody();
     };
-
+	
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // =======================
 
@@ -1822,7 +1838,7 @@
         'getOptions',
         'getSelections', 'getData',
         'load', 'append', 'prepend', 'remove',
-        'insertRow', 'updateRow',
+        'insertRow', 'updateRow', 'showRow', 'hideRow',
         'mergeCells',
         'checkAll', 'uncheckAll',
         'check', 'uncheck',