@@ -1136,6 +1136,38 @@ window.ReactDOM["default"] = window.ReactDOM;
1136
1136
this . tfoot = tfoot ;
1137
1137
1138
1138
this . initializeSorts ( props ) ;
1139
+ this . initializeFilters ( props ) ;
1140
+ }
1141
+ } , {
1142
+ key : 'initializeFilters' ,
1143
+ value : function initializeFilters ( ) {
1144
+ this . _filterable = { } ;
1145
+ // Transform filterable properties into a more friendly list
1146
+ for ( var i in this . props . filterable ) {
1147
+ var column = this . props . filterable [ i ] ;
1148
+ var columnName = undefined ,
1149
+ filterFunction = undefined ;
1150
+
1151
+ if ( column instanceof Object ) {
1152
+ if ( typeof column . column !== 'undefined' ) {
1153
+ columnName = column . column ;
1154
+ } else {
1155
+ console . warn ( 'Filterable column specified without column name' ) ;
1156
+ continue ;
1157
+ }
1158
+
1159
+ if ( typeof column . filterFunction === 'function' ) {
1160
+ filterFunction = column . filterFunction ;
1161
+ } else {
1162
+ filterFunction = 'default' ;
1163
+ }
1164
+ } else {
1165
+ columnName = column
8000
span>;
1166
+ filterFunction = 'default' ;
1167
+ }
1168
+
1169
+ this . _filterable [ columnName ] = filterFunction ;
1170
+ }
1139
1171
}
1140
1172
} , {
1141
1173
key : 'initializeSorts' ,
@@ -1239,12 +1271,21 @@ window.ReactDOM["default"] = window.ReactDOM;
1239
1271
for ( var i = 0 ; i < children . length ; i ++ ) {
1240
1272
var data = children [ i ] . props . data ;
1241
1273
1242
- for ( var j = 0 ; j < this . props . filterable . length ; j ++ ) {
1243
- var filterColumn = this . props . filterable [ j ] ;
1244
-
1245
- if ( typeof data [ filterColumn ] !== 'undefined' && ( 0 , _libExtract_data_from . extractDataFrom ) ( data , filterColumn ) . toString ( ) . toLowerCase ( ) . indexOf ( filter ) > - 1 ) {
1246
- matchedChildren . push ( children [ i ] ) ;
1247
- break ;
1274
+ for ( var filterColumn in this . _filterable ) {
1275
+ if ( typeof data [ filterColumn ] !== 'undefined' ) {
1276
+ // Default filter
1277
+ if ( typeof this . _filterable [ filterColumn ] === 'undefined' || this . _filterable [ filterColumn ] === 'default' ) {
1278
+ if ( ( 0 , _libExtract_data_from . extractDataFrom ) ( data , filterColumn ) . toString ( ) . toLowerCase ( ) . indexOf ( filter ) > - 1 ) {
1279
+ matchedChildren . push ( children [ i ] ) ;
1280
+ break ;
1281
+ }
1282
+ } else {
1283
+ // Apply custom filter
1284
+ if ( this . _filterable [ filterColumn ] ( ( 0 , _libExtract_data_from . extractDataFrom ) ( data , filterColumn ) . toString ( ) , filter ) ) {
1285
+ matchedChildren . push ( children [ i ] ) ;
1286
+ break ;
1287
+ }
1288
+ }
1248
1289
}
1249
1290
}
1250
1291
}
0 commit comments