Dear,
I bought the product last week to implement on my website. Everything works OK but I need a functionality to simplify the search of my clients in the table.
I need a GLOBAL SEARCHING functionallity, like a text box where you can write your search and it filters by any value in any column.
There is an axample from PHPGRID.COM: https://phpgrid.com/example/multiple-fields-global-search/
Is it this possible to have this functionality in this product?
Thanks.
Gabriel.
Yes this is doable. You can refer code of demos/search/search-form.php demo.
It allow external form to do search on your desired fields.
Thanks Abu!
Just another small thing. Could you please let me know how to "Autofilter"? I'd like the filter applies once I write down without touching "Filter" Button.
Thanks
Instead of
jQuery("#search_text").click(…)
You can change it to
jQuery("#filter").keydown(…)
I've not tested it but it's plain JS/Jquery code.
Dear Abu,
I have two more question realted to the above.
1) How do I make the search case-insensitive?
For example:
I have a column "Description" with a register like "Hand Blender"…
When I look for "hand blender" or "HAND BLENDER" there are no results. But yes when I look for "Hand"or "Hard Blender".
I'm using the demo: "demos/search/search-form.phps" and I'm loading the data from an array. I'm also using the Full Version of the Framework. When I use your demo, the search is case insensitive, but not when I use it in my case. I think that it is because i'm loading from array and your not.
The jQuery code for the filter is:
******************************************************************************
jQuery("#search_text").click(function() {
grid = jQuery("#list1");
// open initially hidden grid
// $('.ui-jqgrid-titlebar-close').click();
var searchFiler = jQuery("#filter").val(), f;
if (searchFiler.length === 0) {
grid[0].p.search = false;
jQuery.extend(grid[0].p.postData,{filters:""});
}
f = {groupOp:"OR",rules:[]};
// initialize search, 'name' field equal to (eq) 'Client 1'
// operators: ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
// equal, not equal,
f.rules.push({field:"certificate",op:"bw",data:searchFiler});
f.rules.push({field:"mark",op:"bw",data:searchFiler});
f.rules.push({field:"description",op:"bw",data:searchFiler});
f.rules.push({field:"origin",op:"bw",data:searchFiler});
f.rules.push({field:"products",op:"bw",data:searchFiler});
f.rules.push({field:"OT",op:"bw",data:searchFiler});
grid[0].p.search = true;
jQuery.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
grid.trigger("reloadGrid",[{jqgrid_page:1,current:true}]);
return false;
});
******************************************************************************
2) How do I make the search be anywhere in the String and not from the beginning?
For example:
In the column "Products" I have a register like "KA-CM700, KA-CM600, KC-CT250, KR-CM100". When a search, for example, "KC-CT250", there are no results. I realized that the search is from the beginning of the String.
Please, can you help me with this?
Thanks a lot!
Gabriel.
Hello,
1) Perhaps due to mysql table collation: https://stackoverflow.com/questions/2876789/how-can-i-search-case-insensitive-in-a-column-using-like-wildcard
Without changing database you can set:
$col["dbname"] = "trees.`title` COLLATE UTF8_GENERAL_CI";
It will then use above string in WHERE clause field name.
2) f.rules.push({field:"certificate",op:"bw",data:searchFiler});
Change "bw" to "cn" (begins with to contains)
Abu,
The solution for the 2) point its ok, thank you a lot!
But with 1) … I think the problem is not in the query, because this is done beforehand and then I load the data from an array. I thought of a possible solution, which is to use an extra non-visible column with the Strings in lowercase (This is made easy with the function strtolower ()). Then, when typing the search, transform what is entered in the text box to lowercase, so that there is always a match.
In the code of my previous post (made in Javascript), How can I transform to lowercase the text to Search?
Thank's a lot.
Gabriel.
Abu, I solved the problem. Just setting $grid["ignoreCase"] = true; the search turns case insensitive.
Thanks!