diff options
author | Michael Leibman <michael.leibman@gmail.com> | 2011-11-05 10:46:52 -0700 |
---|---|---|
committer | Michael Leibman <michael.leibman@gmail.com> | 2011-11-05 10:46:52 -0700 |
commit | 0f196f62c6ae1ce642c683b81fb37a97fa2eac6f (patch) | |
tree | 9a553426e8a9af8be0c45ffd4182e748e8809334 | |
parent | 5a5a6a7c616ad42cfe05a99ac92b2d01254b0885 (diff) | |
download | SlickGrid-0f196f62c6ae1ce642c683b81fb37a97fa2eac6f.zip SlickGrid-0f196f62c6ae1ce642c683b81fb37a97fa2eac6f.tar.gz SlickGrid-0f196f62c6ae1ce642c683b81fb37a97fa2eac6f.tar.bz2 |
Fixed example4 and a bug in a DataView filter compilation.
-rw-r--r-- | examples/example4-model.html | 22 | ||||
-rw-r--r-- | slick.dataview.js | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/examples/example4-model.html b/examples/example4-model.html index d961d6b..4c85975 100644 --- a/examples/example4-model.html +++ b/examples/example4-model.html @@ -133,11 +133,11 @@ return {valid:true, msg:null}; } - function myFilter(item) { - if (item["percentComplete"] < percentCompleteThreshold) + function myFilter(item, args) { + if (item["percentComplete"] < args.percentCompleteThreshold) return false; - if (searchString != "" && item["title"].indexOf(searchString) == -1) + if (args.searchString != "" && item["title"].indexOf(args.searchString) == -1) return false; return true; @@ -311,7 +311,7 @@ if (percentCompleteThreshold != ui.value) { window.clearTimeout(h_runfilters); - h_runfilters = window.setTimeout(dataView.refresh, 10); + h_runfilters = window.setTimeout(updateFilter, 10); percentCompleteThreshold = ui.value; } } @@ -327,9 +327,17 @@ this.value = ""; searchString = this.value; - dataView.refresh(); + updateFilter(); }); + function updateFilter() { + dataView.setFilterArgs({ + percentCompleteThreshold: percentCompleteThreshold, + searchString: searchString + }); + dataView.refresh(); + } + $("#btnSelectRows").click(function() { if (!Slick.GlobalEditorLock.commitCurrentEdit()) { return; } @@ -348,6 +356,10 @@ // initialize the model after all the events have been hooked up dataView.beginUpdate(); dataView.setItems(data); + dataView.setFilterArgs({ + percentCompleteThreshold: percentCompleteThreshold, + searchString: searchString + }); dataView.setFilter(myFilter); dataView.endUpdate(); diff --git a/slick.dataview.js b/slick.dataview.js index 56370ce..e3708f8 100644 --- a/slick.dataview.js +++ b/slick.dataview.js @@ -422,7 +422,7 @@ var filterInfo = getFunctionInfo(filter); var filterBody = filterInfo.body.replace(/return ([^;]+?);/gi, - "if ($1) { _retval[_idx++] = $item$; }; continue;"); + "{ if ($1) { _retval[_idx++] = $item$; }; continue; }"); var fnTemplate = function(_items, _args) { var _retval = [], _idx = 0; @@ -446,7 +446,7 @@ var filterInfo = getFunctionInfo(filter); var filterBody = filterInfo.body.replace(/return ([^;]+?);/gi, - "if ((_cache[_i] = $1)) { _retval[_idx++] = $item$; }; continue;"); + "{ if ((_cache[_i] = $1)) { _retval[_idx++] = $item$; }; continue; }"); var fnTemplate = function(_items, _args, _cache) { var _retval = [], _idx = 0; |