@@ -400,6 +400,7 @@ return /******/ (function(modules) { // webpackBootstrap
400
400
keyField: keyField,
401
401
colInfos: this.colInfos,
402
402
multiColumnSearch: props.multiColumnSearch,
403
+ strictSearch: props.strictSearch,
403
404
multiColumnSort: props.multiColumnSort,
404
405
remote: this.props.remote
405
406
});
@@ -748,6 +749,7 @@ return /******/ (function(modules) { // webpackBootstrap
748
749
withoutNoDataText: this.props.options.withoutNoDataText,
749
750
expanding: this.state.expanding,
750
751
onExpand: this.handleExpandRow,
752
+ onlyOneExpanding: this.props.options.onlyOneExpanding,
751
753
beforeShowError: this.props.options.beforeShowError,
752
754
keyBoardNav: this.props.keyBoardNav,
753
755
onNavigateCell: this.handleNavigateCell,
@@ -1452,6 +1454,7 @@ return /******/ (function(modules) { // webpackBootstrap
1452
1454
field: props.dataField,
1453
1455
hiddenOnInsert: props.hiddenOnInsert,
1454
1456
keyValidator: props.keyValidator,
1457
+ customInsertEditor: props.customInsertEditor,
1455
1458
// when you want same auto generate value and not allow edit, example ID field
1456
1459
autoValue: props.autoValue || false,
1457
1460
// for create editor, no params for column.editable() indicate that editor for new row
@@ -1466,6 +1469,7 @@ return /******/ (function(modules) { // webpackBootstrap
1466
1469
name: children.props.headerText || children.props.children,
1467
1470
field: children.props.dataField,
1468
1471
editable: children.props.editable,
1472
+ customInsertEditor: children.props.customInsertEditor,
1469
1473
hiddenOnInsert: children.props.hiddenOnInsert,
1470
1474
keyValidator: children.props.keyValidator
1471
1475
}];
@@ -1706,6 +1710,8 @@ return /******/ (function(modules) { // webpackBootstrap
1706
1710
insertRow: _react.PropTypes.bool,
1707
1711
deleteRow: _react.PropTypes.bool,
1708
1712
search: _react.PropTypes.bool,
1713
+ multiColumnSearch: _react.PropTypes.bool,
1714
+ strictSearch: _react.PropTypes.bool,
1709
1715
columnFilter: _react.PropTypes.bool,
1710
1716
trClassName: _react.PropTypes.any,
1711
1717
tableStyle: _react.PropTypes.object,
@@ -1789,6 +1795,7 @@ return /******/ (function(modules) { // webpackBootstrap
1789
1795
expandRowBgColor: _react.PropTypes.string,
1790
1796
expandBy: _react.PropTypes.string,
1791
1797
expanding: _react.PropTypes.array,
1798
+ onlyOneExpanding: _react.PropTypes.bool,
1792
1799
beforeShowError: _react.PropTypes.func,
1793
1800
printToolBar: _react.PropTypes.bool
1794
1801
}),
@@ -1851,6 +1858,7 @@ return /******/ (function(modules) { // webpackBootstrap
1851
1858
deleteRow: false,
1852
1859
search: false,
1853
1860
multiColumnSearch: false,
1861
+ strictSearch: undefined,
1854
1862
multiColumnSort: 1,
1855
1863
columnFilter: false,
1856
1864
trClassName: '',
@@ -1932,6 +1940,7 @@ return /******/ (function(modules) { // webpackBootstrap
1932
1940
expandRowBgColor: undefined,
1933
1941
expandBy: _Const2.default.EXPAND_BY_ROW,
1934
1942
expanding: [],
1943
+ onlyOneExpanding: false,
1935
1944
beforeShowError: undefined,
1936
1945
printToolBar: true
1937
1946
},
@@ -2870,7 +2879,8 @@ return /******/ (function(modules) { // webpackBootstrap
2870
2879
keyField = _props4.keyField,
2871
2880
expandBy = _props4.expandBy,
2872
2881
expandableRow = _props4.expandableRow,
2873
- clickToExpand = _props4.selectRow.clickToExpand;
2882
+ clickToExpand = _props4.selectRow.clickToExpand,
2883
+ onlyOneExpanding = _props4.onlyOneExpanding;
2874
2884
2875
2885
var selectRowAndExpand = this._isSelectRowDefined() && !clickToExpand ? false : true;
2876
2886
columnIndex = this._isSelectRowDefined() ? columnIndex - 1 : columnIndex;
@@ -2887,7 +2897,7 @@ return /******/ (function(modules) { // webpackBootstrap
2887
2897
return k !== rowKey;
2888
2898
});
2889
2899
} else {
2890
- expanding.push(rowKey);
2900
+ if (onlyOneExpanding) expanding = [rowKey];else expanding.push(rowKey);
2891
2901
}
2892
2902
_this2.props.onExpand(expanding);
2893
2903
})();
@@ -3083,6 +3093,7 @@ return /******/ (function(modules) { // webpackBootstrap
3083
3093
expandBy: _react.PropTypes.string,
3084
3094
expanding: _react.PropTypes.array,
3085
3095
onExpand: _react.PropTypes.func,
3096
+ onlyOneExpanding: _react.PropTypes.bool,
3086
3097
beforeShowError: _react.PropTypes.func,
3087
3098
keyBoardNav: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.object]),
3088
3099
x: _react.PropTypes.number,
@@ -13571,6 +13582,8 @@ return /******/ (function(modules) { // webpackBootstrap
13571
13582
if (column.editable && column.editable.type === 'checkbox') {
13572
13583
var values = inputVal.split(':');
13573
13584
inputVal = dom.checked ? values[0] : values[1];
13585
+ } else if (column.customInsertEditor) {
13586
+ inputVal = inputVal || dom.getFieldValue();
13574
13587
}
13575
13588
}
13576
13589
newRow[column.field] = inputVal;
@@ -13594,12 +13607,22 @@ return /******/ (function(modules) { // webpackBootstrap
13594
13607
field = column.field,
13595
13608
name = column.name,
13596
13609
autoValue = column.autoValue,
13597
- hiddenOnInsert = column.hiddenOnInsert;
13610
+ hiddenOnInsert = column.hiddenOnInsert,
13611
+ customInsertEditor = column.customInsertEditor;
13598
13612
13599
13613
var attr = {
13600
13614
ref: field + i,
13601
13615
placeholder: editable.placeholder ? editable.placeholder : name
13602
13616
};
13617
+ var fieldElement = void 0;
13618
+
13619
+ if (customInsertEditor) {
13620
+ var getElement = customInsertEditor.getElement;
13621
+
13622
+ fieldElement = getElement(column, attr, 'form-control', ignoreEditable);
13623
+ } else {
13624
+ fieldElement = (0, _Editor2.default)(editable, attr, format, '', undefined, ignoreEditable);
13625
+ }
13603
13626
13604
13627
if (autoValue || hiddenOnInsert || !column.field) {
13605
13628
// when you want same auto generate value
@@ -13619,7 +13642,7 @@ return /******/ (function(modules) { // webpackBootstrap
13619
13642
null,
13620
13643
name
13621
13644
),
13622
- (0, _Editor2.default)(editable, attr, format, '', undefined, ignoreEditable) ,
13645
+ fieldElement ,
13623
13646
error
13624
13647
);
13625
13648
})
@@ -14491,18 +14514,14 @@ return /******/ (function(modules) { // webpackBootstrap
14491
14514
};
14492
14515
14493
14516
this.data = data;
14494
- this.colInfos = null;
14495
14517
this.filteredData = null;
14496
14518
this.isOnFilter = false;
14497
14519
this.filterObj = null;
14498
14520
this.searchText = null;
14499
14521
this.sortList = [];
14500
14522
this.pageObj = {};
14501
14523
this.selected = [];
14502
- this.multiColumnSearch = false;
14503
- this.multiColumnSort = 1;
14504
14524
this.showOnlySelected = false;
14505
- this.remote = false; // remote data
14506
14525
}
14507
14526
14508
14527
_createClass(TableDataStore, [{
@@ -14513,6 +14532,8 @@ return /******/ (function(modules) { // webpackBootstrap
14513
14532
this.colInfos = props.colInfos;
14514
14533
this.remote = props.remote;
14515
14534
this.multiColumnSearch = props.multiColumnSearch;
14535
+ // default behaviour if strictSearch prop is not provided: !multiColumnSearch
14536
+ this.strictSearch = typeof props.strictSearch === 'undefined' ? !props.multiColumnSearch : props.strictSearch;
14516
14537
this.multiColumnSort = props.multiColumnSort;
14517
14538
}
14518
14539
}, {
@@ -15077,57 +15098,82 @@ return /******/ (function(modules) { // webpackBootstrap
15077
15098
});
15078
15099
this.isOnFilter = true;
15079
15100
}
15101
+
15102
+ /*
15103
+ * Four different sort modes, all case insensitive:
15104
+ * (1) strictSearch && !multiColumnSearch
15105
+ * search text must be contained as provided in a single column
15106
+ * (2) strictSearch && multiColumnSearch
15107
+ * conjunction (AND combination) of whitespace separated terms over multiple columns
15108
+ * (3) !strictSearch && !multiColumnSearch
15109
+ * conjunction (AND combination) of whitespace separated terms in a single column
15110
+ * (4) !strictSearch && multiColumnSearch
15111
+ * any of the whitespace separated terms must be contained in any column
15112
+ */
15113
+
15080
15114
}, {
15081
15115
key: '_search',
15082
15116
value: function _search(source) {
15083
15117
var _this7 = this;
15084
15118
15085
- var searchTextArray = [] ;
15086
-
15087
- if (this.multiColumnSearch) {
15088
- searchTextArray = this.searchText.split(' ' );
15119
+ var searchTextArray = void 0 ;
15120
+ if (this.multiColumnSearch || !this.strictSearch) {
15121
+ // ignore leading and trailing whitespaces
15122
+ searchTextArray = this.searchText.trim().toLowerCase(). split(/\s+/ );
15089
15123
} else {
15090
- searchTextArray.push( this.searchText) ;
15124
+ searchTextArray = [ this.searchText.toLowerCase()] ;
15091
15125
}
15126
+ var searchTermCount = searchTextArray.length;
15127
+ var multipleTerms = searchTermCount > 1;
15128
+ var nonStrictMultiCol = multipleTerms && !this.strictSearch && this.multiColumnSearch;
15129
+ var nonStrictSingleCol = multipleTerms && !this.strictSearch && !this.multiColumnSearch;
15092
15130
this.filteredData = source.filter(function (row, r) {
15093
15131
var keys = Object.keys(row);
15094
- var valid = false;
15132
+ // only clone array if necessary
15133
+ var searchTerms = multipleTerms ? searchTextArray.slice() : searchTextArray;
15095
15134
// for loops are ugly, but performance matters here.
15096
15135
// And you cant break from a forEach.
15097
15136
// http://jsperf.com/for-vs-foreach/66
15098
15137
for (var i = 0, keysLength = keys.length; i < keysLength; i++) {
15099
15138
var key = keys[i];
15100
- // fixed data filter when misunderstand 0 is false
15101
- var filterSpecialNum = false;
15102
- if (!isNaN(row[key]) && parseInt(row[key], 10) === 0) {
15103
- filterSpecialNum = true;
15104
- }
15105
- if (_this7.colInfos[key] && (row[key] || filterSpecialNum)) {
15106
- var _colInfos$key = _this7.colInfos[key],
15107
- format = _colInfos$key.format,
15108
- filterFormatted = _colInfos$key.filterFormatted,
15109
- filterValue = _colInfos$key.filterValue,
15110
- formatExtraData = _colInfos$key.formatExtraData,
15111
- searchable = _colInfos$key.searchable;
15112
-
15113
- var targetVal = row[key];
15114
- if (searchable) {
15115
- if (filterFormatted && format) {
15116
- targetVal = format(targetVal, row, formatExtraData, r);
15117
- } else if (filterValue) {
15118
- targetVal = filterValue(targetVal, row);
15139
+ var colInfo = _this7.colInfos[key];
15140
+ if (colInfo && colInfo.searchable) {
15141
+ var format = colInfo.format,
15142
+ filterFormatted = colInfo.filterFormatted,
15143
+ filterValue = colInfo.filterValue,
15144
+ formatExtraData = colInfo.formatExtraData;
15145
+
15146
+ var targetVal = void 0;
15147
+ if (filterFormatted && format) {
15148
+ targetVal = format(row[key], row, formatExtraData, r);
15149
+ } else if (filterValue) {
15150
+ targetVal = filterValue(row[key], row);
15151
+ } else {
15152
+ targetVal = row[key];
15153
+ }
15154
+ if (targetVal !== null && typeof targetVal !== 'undefined') {
15155
+ targetVal = targetVal.toString().toLowerCase();
15156
+ if (nonStrictSingleCol && searchTermCount > searchTerms.length) {
15157
+ // reset search terms for single column search
15158
+ searchTerms = searchTextArray.slice();
15119
15159
}
15120
- for (var j = 0, textLength = searchTextArray.length; j < textLength; j++) {
15121
- var filterVal = searchTextArray[j].toLowerCase();
15122
- if (targetVal.toString().toLowerCase().indexOf(filterVal) !== -1) {
15123
- valid = true;
15160
+ for (var j = searchTerms.length - 1; j > -1; j--) {
15161
+ if (targetVal.indexOf(searchTerms[j]) !== -1) {
15162
+ if (nonStrictMultiCol || searchTerms.length === 1) {
15163
+ // match found: the last or only one
15164
+ return true;
15165
+ }
15166
+ // match found: but there are more search terms to check for
15167
+ searchTerms.splice(j, 1);
15168
+ } else if (!_this7.multiColumnSearch) {
15169
+ // one of the search terms was not found in this column
15124
15170
break;
15125
15171
}
15126
15172
}
15127
15173
}
15128
15174
}
15129
15175
}
15130
- return valid ;
15176
+ return false ;
15131
15177
});
15132
15178
this.isOnFilter = true;
15133
15179
}
0 commit comments