HandsonTableの検索結果フィルタ表示が意外と簡単に 実装できた。すばらしい。 こうして ---------------------------------- var searchField = document.getElementById("searchField"); var resultCount = document.getElementById("resultCount"); Handsontable.Dom.addEvent(searchField, 'keyup', function(event) { filter(('' + this.value).toLowerCase()); resultRow = hot.countRows()-1; //0スタートなので-1が必要 resultCount.innerText = "検索結果:" + resultRow.toString() + "件"; }); --------------------------- こう -------------------------------- function filter(search) { var row, r_len, data = myData, // Keeping the integretity of the original data array = []; for (row = 0, r_len = data.length; row < r_len; row++) { for(col = 0, c_len = data[row].length; col < c_len; col++) { if(('' + data[row][col]).toLowerCase().indexOf(search) > -1) { array.push(data[row]); break; } } } hot.loadData(array); } --------------------------------  I'm currently trying to add a search filter on a column in handsontable. I can use the callback of the search plugin to hide the rows with css but that breaks scrolling. The search plugin also seem...

HandsonTableの検索結果フィルタ表示が意外と簡単に 実装できた。すばらしい。 こうして ---------------------------------- var searchField...
=======================================
HandsonTableの検索結果フィルタ表示が意外と簡単に
実装できた。すばらしい。

こうして
----------------------------------
var searchField = document.getElementById("searchField");
var resultCount = document.getElementById("resultCount");

Handsontable.Dom.addEvent(searchField, 'keyup', function(event) {
filter(('' + this.value).toLowerCase());
resultRow = hot.countRows()-1; //0スタートなので-1が必要
resultCount.innerText = "検索結果:" + resultRow.toString() + "件";
});

---------------------------
こう
--------------------------------
function filter(search) {
var
row, r_len,
data = myData, // Keeping the integretity of the original data
array = [];
for (row = 0, r_len = data.length; row < r_len; row++) {
for(col = 0, c_len = data[row].length; col < c_len; col++) {
if(('' + data[row][col]).toLowerCase().indexOf(search) > -1) {
array.push(data[row]);
break;
}
}
}
hot.loadData(array);
}
--------------------------------



http://ift.tt/1abnmbU
December 20, 2016 at 04:13PM

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)