How to handle multiple dropdown filters on a page in Angular 6?How to use jQuery with Angular?How to detect a route change in Angular?Angular 2 - How to listen to event without a template?How can I close a dropdown on click outside?How to bundle an Angular app for productionAngular 2 router evaluating multiple route parametersAngular 2: can custom component handle its own events?Filtering Results of Observable Before Subscribing in Angular AppBuilding an API Call Holding Multiple Filter-selected Values in Angular AppModifying the CSS of ng2-completer
Permission on Database
Mimic lecturing on blackboard, facing audience
Circuit Analysis: Obtaining Close Loop OP - AMP Transfer function
Taxes on Dividends in a Roth IRA
Has the laser at Magurele, Romania reached a tenth of the Sun's power?
What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?
Is there a nicer/politer/more positive alternative for "negates"?
The IT department bottlenecks progress, how should I handle this?
How to explain what's wrong with this application of the chain rule?
How to draw a matrix with arrows in limited space
Pre-mixing cryogenic fuels and using only one fuel tank
Make a Bowl of Alphabet Soup
Review your own paper in Mathematics
What is the difference between lands and mana?
Which was the first story featuring espers?
What is the English pronunciation of "pain au chocolat"?
What kind of floor tile is this?
Why is so much work done on numerical verification of the Riemann Hypothesis?
Is it necessary to use pronouns with the verb "essere"?
Is my low blitz game drawing rate at www.chess.com an indicator that I am weak in chess?
Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?
How to make money from a browser who sees 5 seconds into the future of any web page?
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Does Doodling or Improvising on the Piano Have Any Benefits?
How to handle multiple dropdown filters on a page in Angular 6?
How to use jQuery with Angular?How to detect a route change in Angular?Angular 2 - How to listen to event without a template?How can I close a dropdown on click outside?How to bundle an Angular app for productionAngular 2 router evaluating multiple route parametersAngular 2: can custom component handle its own events?Filtering Results of Observable Before Subscribing in Angular AppBuilding an API Call Holding Multiple Filter-selected Values in Angular AppModifying the CSS of ng2-completer
So here is the scenario:
There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.
The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.
Is there is simpler approach to handling such case ?
Thanks.
angular
|
show 3 more comments
So here is the scenario:
There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.
The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.
Is there is simpler approach to handling such case ?
Thanks.
angular
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
1
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55
|
show 3 more comments
So here is the scenario:
There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.
The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.
Is there is simpler approach to handling such case ?
Thanks.
angular
So here is the scenario:
There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.
The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.
Is there is simpler approach to handling such case ?
Thanks.
angular
angular
asked Mar 7 at 5:02
Mukul_VashisthaMukul_Vashistha
2113
2113
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
1
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55
|
show 3 more comments
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
1
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
1
1
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55
|
show 3 more comments
1 Answer
1
active
oldest
votes
First check all of them to see if they are -1
if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values
this way you sure that in the else block non of them is null or -1,hope it helps
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036412%2fhow-to-handle-multiple-dropdown-filters-on-a-page-in-angular-6%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First check all of them to see if they are -1
if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values
this way you sure that in the else block non of them is null or -1,hope it helps
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
add a comment |
First check all of them to see if they are -1
if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values
this way you sure that in the else block non of them is null or -1,hope it helps
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
add a comment |
First check all of them to see if they are -1
if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values
this way you sure that in the else block non of them is null or -1,hope it helps
First check all of them to see if they are -1
if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values
this way you sure that in the else block non of them is null or -1,hope it helps
answered Mar 7 at 6:10
ehsan kianiehsan kiani
1128
1128
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
add a comment |
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.
– Mukul_Vashistha
Mar 7 at 9:09
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
Have you consider pushing all filters in array and send it to server?
– ehsan kiani
Mar 7 at 15:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036412%2fhow-to-handle-multiple-dropdown-filters-on-a-page-in-angular-6%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?
– Krishna
Mar 7 at 5:22
@Krishna- Yes Sir and the data displayed should be matching the applied filter/s
– Mukul_Vashistha
Mar 7 at 5:26
Is it your own API or something from a 3rd party?
– abney317
Mar 7 at 5:32
1
Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe
– Krishna
Mar 7 at 5:40
@abney317 - Our own API.
– Mukul_Vashistha
Mar 7 at 5:55