SearchBuilder: How to pre-populate search values inside SearchBuilder values dropdown menu?

SearchBuilder: How to pre-populate search values inside SearchBuilder values dropdown menu?

fiji885fiji885 Posts: 7Questions: 3Answers: 0

Link to test case: http://live.datatables.net/veboboki/1/edit

Description of problem:
One of my use-case of DataTables involved ajax + server side rendering. One of the table columns I have is called 'Status', and I would like SearchBuilder to display all statuses even if they're not in the table.

My possible column values for statuses are ['online', 'offline', 'pending', 'error'], but if there are no records in the DataTable that contain one of them, I will not be able to see them. How can I make it so SearchBuilder shows them?

Current

Expected

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @fiji885 ,

    You are going to have to modify the searchBuilder.conditions[type][cond].init function to make sure that it always adds in all of the values that you are after. The default init function for select elements can be found here. You would copy the code from there, and set it in your SearchBuilder initialisation with whatever changes you required to add the other options.

    It would also be worth looking at this page for pointers.

    Thanks,
    Sandy

  • ECEGROUPEECEGROUPE Posts: 77Questions: 28Answers: 1
    edited March 2022

    Hi @fiji885 ,

    I'm interested about this subject because i have almost the same problem... Have you find a solution and can you share it pls ?

    Thank you in advance :)

  • ECEGROUPEECEGROUPE Posts: 77Questions: 28Answers: 1

    Or maybe @Sandy can you please give us a code exemple on how to add one more options to the dropdown menu pls ?

    Thx :)

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @ECEGROUPE ,

    Take a look a this example. There are a few changes required to the function I linked above as it is in typescript. The main addition to get this working is

    /*****************************************************************************************/
    addOption("AlwaysPresent", "AlwaysPresent")
    /*****************************************************************************************/
    

    Hope this helps,
    Sandy

Sign In or Register to comment.