2

Flexigrid is a nice jQuery grid, and pretty customizable, but the quick search feature only allows for exact searches (as far as I can tell). Anybody know a fix or workaround for this? I've tried adding wildcard characters to the "p.query" string, but no luck.

FYI: This is for use with a MySQL database and PHP, so the wildcard I tried to add was '%'.

Here's the "doSearch" function in the flexigrid.js:

doSearch: function () {
   p.query = $('input[name=q]', g.sDiv).val();
   p.qtype = $('select[name=qtype]', g.sDiv).val();
   p.newp = 1;
   this.populate();
},

Thanks for the help!

gtr1971
  • 2,672
  • 2
  • 18
  • 23

1 Answers1

1

The best answer I could devise on my own was changing the SQL query on the PHP side to have a LIKE clause instead of an EQUAL TO clause, using the appropriate wildcard character "%".

I was hoping to find a javascript/jQuery wildcard on the client end that would be appended to the search string, but my search didn't turn up any answers for that.

The line I changed in the PHP script is as follows:

$searchSql = ($qtype != '' && $query != '') ? "where $qtype like CONCAT('%','$query','%') and UserID = $id" : "where UserID = $id";

instead of:

$searchSql = ($qtype != '' && $query != '') ? "where $qtype = '$query' and UserID = $id" : "where UserID = $id";

Best of luck!

gtr1971
  • 2,672
  • 2
  • 18
  • 23