Browse Source

Fix #964: Added and methods.

zhixin 10 years ago
parent
commit
a16b087ac1
2 changed files with 18 additions and 1 deletions
  1. 2 0
      CHANGELOG.md
  2. 16 1
      src/bootstrap-table.js

+ 2 - 0
CHANGELOG.md

@@ -26,6 +26,8 @@
 - [enh] Improved reorder-columns extension.
 - [enh] Added multiple-search, accent-neutralise extension.
 - [enh] Added fixed-columns extension.
+- [enh] Added `$.fn.bootstrapTable.utils` tools.
+- [enh] Added `expandRow` and `collapseRow` methods.
 
 ### 1.8.1
 

+ 16 - 1
src/bootstrap-table.js

@@ -2478,6 +2478,20 @@
         this.onSearch({currentTarget: $search});
     };
 
+    BootstrapTable.prototype.expandRow = function (index) {
+        var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
+        if (!$tr.next().is('tr.detail-view')) {
+            $tr.find('> td > .detail-icon').click();
+        }
+    };
+
+    BootstrapTable.prototype.collapseRow = function (index) {
+        var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
+        if ($tr.next().is('tr.detail-view')) {
+            $tr.find('> td > .detail-icon').click();
+        }
+    };
+
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // =======================
 
@@ -2504,7 +2518,8 @@
         'togglePagination',
         'toggleView',
         'refreshOptions',
-        'resetSearch'
+        'resetSearch',
+        'expandRow', 'collapseRow'
     ];
 
     $.fn.bootstrapTable = function (option) {