File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ You must include the bootstrap-table-group-by.css file in order to get the appro
3333### groupByInitExpanded
3434
3535* type: Boolean
36- * description: Set to True to expand the first node of the table.
37- * default: ` false `
36+ * description: You can use the node number (parent row index) or you can use the ` all ` option in order to expand all nodes of the table.
37+ * default: ` undefined `
3838
3939## Methods
4040
Original file line number Diff line number Diff line change 1414 obj = { } ,
1515 parentId = undefined ;
1616
17+ var getParentRowId = function ( that , id ) {
18+ var parentRows = that . $body . find ( 'tr' ) . not ( '[' + 'data-tt-parent-id]' ) ;
19+
20+ for ( var i = 0 ; i < parentRows . length ; i ++ ) {
21+ if ( i === id ) {
22+ return $ ( parentRows [ i ] ) . attr ( 'data-tt-id' ) ;
23+ }
24+ }
25+
26+ return undefined ;
27+ } ;
28+
1729 var sumData = function ( that , data ) {
1830 var sumRow = { } ;
1931 $ . each ( data , function ( i , row ) {
109121 groupBy : false ,
110122 groupByField : '' ,
111123 groupBySumGroup : false ,
112- groupByInitExpanded : false ,
124+ groupByInitExpanded : undefined , //node, 'all'
113125 //internal variables
114126 loaded : false ,
115127 originalData : undefined
156168 }
157169 } , true ) ;
158170
159- if ( that . options . groupByInitExpanded ) {
160- that . expandNode ( '0' ) ;
171+ if ( that . options . groupByInitExpanded !== undefined ) {
172+ if ( typeof that . options . groupByInitExpanded === 'number' ) {
173+ that . expandNode ( that . options . groupByInitExpanded ) ;
174+ } else if ( that . options . groupByInitExpanded . toLowerCase ( ) === 'all' ) {
175+ that . expandAll ( ) ;
176+ }
161177 }
162178 } ) ;
163179 }
184200 } ;
185201
186202 BootstrapTable . prototype . expandNode = function ( id ) {
187- this . $el . treetable ( 'expandNode' , id ) ;
203+ id = getParentRowId ( this , id ) ;
204+ if ( id !== undefined ) {
205+ this . $el . treetable ( 'expandNode' , id ) ;
206+ }
188207 }
189208} ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments