-
Notifications
You must be signed in to change notification settings - Fork 361
Question: How do you filter by columns? #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For my tables with enabled ajax I did it like this (this does not work for client-side only tables): Create your own search form with the search fields you want to have. Add these custom search values to your ajax requests like this: $('#grid').bootgrid({
ajax : true,
url : '/this/is/the/ajax/url',
otherStuff : ... ,
requestHandler : function (request) {
request.searchVal1 = $('#search-field-1').val();
request.searchVal2 = $('#search-field-2').val();
return request;
}
}); This would send the search values on every ajax request and you can use it on the server to filter the rows. Probably you want to filter the rows as soon as you change one of the custom search fields. I did it like this: // we only want to trigger the reload 0.5 seconds after the last input event
// so we use this variable to have a reference to the timeout
// then we can clear the timeout if we get another input within the 0.5 seconds
var searchTimeout = null;
$('#search-form').find('input, select').on('input', function () {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(function () {
// just reload the bootgrid.
// Search values will be appended by the requestHandler defined above
$('#grid').bootgrid('reload');
}, 500);
}); As mentioned above this approach only works for ajax-enabled tables. |
Thats a good idea! at then I did it really differently not using the ajax request.....but filtering the parameters by get....nasty. how did you add the filter values (selects/inputs) to the search form so gets properly integrated? |
Actually I just disabled the built-in search field and added my search form outside of the bootgrid. To add it to the actual bootgrid, you can probably use the templates.header or templates.search for it: http://www.jquery-bootgrid.com/Documentation#templates |
thanks a lot I will take a look ;) |
See pull request #280 |
Hello,
Great job on this software. I know you do not have filter by columns and I am thinking in different work arounds.
Anyone has done it? any feedback or help appreciated.
thanks.
The text was updated successfully, but these errors were encountered: