In datatables,How can we cascade dropdown data while using multiple dropdowns for search

In datatables,How can we cascade dropdown data while using multiple dropdowns for search

LearningfingerLearningfinger Posts: 5Questions: 1Answers: 0

Datatables according to us has fantastic features. We have found lots of solutions from this forum. Thanks.
We were trying to build a search with dropdown values. All is well but for this case.
Simple Example Scenario to help understanding(not the real case) -
Datatables shows country city and say population
Say we have a dropdown search for country and city
When country dropdown has a value selected for country , only the cities of that country should be shown in the city dropdown.
How can this be achieved ? We are using the standard way ie code in the initComplete method for populating the dropdowns.

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @Learningfinger ,

    Take a look at this example here, this does something similar. The dropdowns are dependent upon the selection on the others to the left.

    Hope that helps,

    Cheers,

    Colin

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    This blog post covers a pretty similar scenario:
    https://datatables.net/blog/2017-09-01

  • LearningfingerLearningfinger Posts: 5Questions: 1Answers: 0

    Thanks Colin, but i have not used yadcf till now.

    It will take time to understand and port our requirement to yadcf. Our site is already live
    https://www.learningfinger.com/booklist

    When i started researching for dropdown searches, i did find yadcf do amazing things. iam sure it has used the features and hooks of datatables to do it. I was wondering why there is no discussion or documentation of how it can be achieved using the base datatables api hooks directly. Any leads in this direction would be helpful

  • LearningfingerLearningfinger Posts: 5Questions: 1Answers: 0

    Thanks Tangerine. We are not using editor version of datatables.

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    I was wondering why there is no discussion or documentation of how it can be achieved using the base datatables api hooks directly.

    That's all YADCF is doing - it just uses the DataTables API to achieve what it does. If you were to do something similar, you'd probably end up rewriting what YADCF already does :)

    YADCF just uses DataTables, so it won't require a port in anyway - you just use it to construct any custom searches that you want.

    C

  • LearningfingerLearningfinger Posts: 5Questions: 1Answers: 0

    Ok. Thx. Agree.
    But i did see the constructs of yadcf to define and customise columns of the table- a little different than normal datatables and hence was considering the porting effort.

  • LearningfingerLearningfinger Posts: 5Questions: 1Answers: 0

    One more question, yadcf says

    Filters can be placed in the header (thead) or in the footer (tfoot) , second argument of yadcf constructor or third argument of init function

    Is it possible to add the filters in altogether separate div....something like a search pane ?

This discussion has been closed.