mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.81k stars 1.98k forks source link

What is preventing this (example 4) search implementation from updating the dataView? #1088

Closed Fcasualty closed 8 years ago

Fcasualty commented 8 years ago

example 4: https://github.com/mleibman/SlickGrid/blob/gh-pages/examples/example4-model.html

When typing in the search box, the dataView display does not change.

Please indicate whether you see the culprit or whether anything else needs posted.

Notes:

Is this problem related to the components' scope?

The starting line of each search component and wrapping function is noted below.

<span style="float:right" class="ui-icon ui-icon-search" title="Toggle search panel"
                                onclick="toggleFilterRow()"></span>

<div id="inlineFilterPanel" style="display:none;background:#dddddd;padding:3px;color:black;">
  Search: <input type="text" id="txtSearch2">
  <div style="width:100px;display:inline-block;"></div>
</div>

// line #'s paired with each search component

// 361: 
<script type="text/javascript"> // encapsulates all

// 901: var dataView;

// 1062: 
var searchString = "";

// 1348: 
function myFilter(item, args) {

  if (args.searchString != "" && item["file_name"].indexOf(args.searchString) == -1) {
    return false;
  }

  return true;
}

// 1379:
    function toggleFilterRow() {
         grid.setTopPanelVisibility(!grid.getOptions().showTopPanel);
        }

// 1632: 
jQuery(document).ready(function() { … }); // ends at line 2556

// 1841: getJSON call
// grid is created and its data retrieved

// 2029:
dataView = new Slick.Data.DataView({ inlineFilters: true });

// 2035:
// move the filter panel defined in a hidden div into grid top panel
$("#inlineFilterPanel")
    .appendTo(grid.getTopPanel())
    .show();

// 2462:
$("#txtSearch2").keyup(function (e) {
        Slick.GlobalEditorLock.cancelCurrentEdit();

        // clear on Esc
        if (e.which == 27) {
          this.value = "";
        }

        searchString = this.value;
        updateFilter();
      });
      $("#txtSearch2").click(function (e) {
          inSearchBox = true;
      });

      function updateFilter() {
        dataView.setFilterArgs({
          searchString: searchString
        });
        dataView.refresh();

      }

// 2502:
dataView.beginUpdate();
dataView.setItems(data);

dataView.setFilterArgs({
          searchString: searchString
      });
dataView.setFilter(myFilter);
dataView.endUpdate();

   }); // 2517: ends getJSON call

}); // 2556: ends jQuery(document).ready call
6pac commented 8 years ago

I've checked out the live example http://mleibman.github.io/SlickGrid/examples/example4-model.html

Works fine here on Chrome on WinXP. Can you post your browser version and check in the console to see if any error messages are being thrown ?

Fcasualty commented 8 years ago

I haven't received any errors, and remember having successfully tested the example before any modifications.

I just noticed that only the first row starts as selected and will stay highlighted as long as the text matches. No other rows disappear or are highlighted when their text matches.

6pac commented 8 years ago

I'm not clear on whether you are having problems with the example straight off GitHub, or if you have modified that example and are having problems with your modified version. If you are having problems with the GitHub example, I've stated I'm not seeing the problem here so it comes down to likely browser issues or code changes. You need to tell us the environment you're having problem with (eg. Windows 7, IE9). If you are having problems with a modified version of the example, there is no other way really than applying all your changes to the original example, one step at a time, checking that each step works. If you want help, you'd need to post the entire example so we can run it on our own systems. Also, problems with implementation should be posted to StackOverflow, not here. GitHub is for bugs or enhancements to the codebase.

Fcasualty commented 8 years ago

6pac, Thank you for the explanation and the first response to this issue on any medium, which is why it was posted here (aside from my novelty at github). There has been a post on StackOverflow and SlickGrid google group. I get to look more into this today, finally, so there may be updates.