I have a button that is performing a get to my page and adding a filter to the query string. My code applies that filter to the grid but the user can remove/edit that filter. Since they can see what filter was applied in the grid, I would like to remove the ?filter=blah
from the query string when the page is displayed.
It might be confusing if on the page and the URL says ?filter=columnA
which is correct initially, but the user removes that filter and applies a new one on columnB
but the query string still says ?filter-columnA
. The grid can handle changing filters without needing a post back.
How can I do that? And if you cannot remove/update a query string, is it possible to parse it and then just redirect to the main page without the query string? Once I have the filter saved to var filter, I no longer need it in the query string.
here is the code that displays the page:
exports.show = function(req, res) {
var filter = req.query.filter;
if (filter === null || filter === "") {
filter = "n/a";
}
res.render("somepage.jade", {
locals: {
title: "somepage",
filter: filter
}
});
};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…