Koala Koala - 5 months ago 101
Ajax Question

update parameters variable on change.search using bootgrid with structured-filter

I am using https://github.com/evoluteur/structured-filter and http://www.jquery-bootgrid.com/ to create an advanced search through ajax/php.

Initially the code works and returns the data from the php file, but when trying to use structured-filter to pass

$_GET
variables to the php file through the use of jquery-bootgrid I am struggling.

No matter what I try, the url it is posting to has no
$_GET
variables, I have tried
$("#grid-data").bootgrid("reload");
but nothing changes.

It appears the
params
variable is just not updating.

Here is my jquery script in full:

<script type="text/javascript">
$(document).ready(function() {
$("#myFilter").structFilter({
fields: [{
type: "text",
id: "gamertag",
label: "Gamertag"
}, {
type: "text",
id: "name",
label: "Team Name"
}, {
type: "number",
id: "wagePerMatch",
label: "Wage Per Match"
}, {
type: "number",
id: "gamesRemaining",
label: "Contract Games Remanining"
}, {
type: "boolean",
id: "transferListed",
label: "Transfer Listed"
}

]
});

var params = "";
$("#myFilter").on("change.search", function(event) {
var params = $("#myFilter").structFilter("valUrl");
$("#grid-data").bootgrid("reload");
console.log(params); // works, returns params
});



$("#grid-data").bootgrid({
ajax: true,
url: function() {
return "/api/search.php?" + params; // params never updates?
}
});


});
</script>


Is there a way to update params in
.bootgrid
when it changes in
$("#myFilter").on("change.search"
as right now its only sending requests to
/api/search.php?
(missing the parameters)

Answer
Now i don't have to much reputation, i am unable to add comment on this,

Please check this below URL, hope this will help you

http://www.jquery-bootgrid.com/Documentation#events

if you are looking for append the rows in existing grid so you can use "append" as given in URL or if you want to update the whole table you can destory the table and re-create a "bootgrid" object with binding with the respective DOM id's

Comments