2

Flexigrid 是一个不错的 jQuery 网格,并且非常可定制,但快速搜索功能只允许精确搜索(据我所知)。有人知道解决方法或解决方法吗?我尝试将通配符添加到“p.query”字符串,但没有运气。

仅供参考:这是用于 MySQL 数据库和 PHP,所以我尝试添加的通配符是 '%'。

这是 flexigrid.js 中的“doSearch”函数:

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

谢谢您的帮助!

4

1 回答 1

1

我可以自己设计的最佳答案是使用适当的通配符“%”将 PHP 端的 SQL 查询更改为具有 LIKE 子句而不是 EQUAL TO 子句。

我希望在客户端找到一个 javascript/jQuery 通配符,该通配符将附加到搜索字符串中,但我的搜索没有找到任何答案。

我在 PHP 脚本中更改的行如下:

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

代替:

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

祝你好运!

于 2012-01-24T17:50:27.233 回答