Searchbuilder buttoned how to fix a constant column ?

Searchbuilder buttoned how to fix a constant column ?

NeurolinkedNeurolinked Posts: 2Questions: 0Answers: 0
edited January 7 in Free community support

I'm trying to wrap my head around searchBuilder and its configuration.
In my case i need only a column to be searched, so i want to be the only column to be auto-selected for every new condition i add
This column in my datas contains strings commas separated.
Since i'm using only that column with searchbuilder how can i autoselect for every new init condition the only column that is in the list ??
There is an event that i can use to set a default predefined column to be searched on ??

My button is configured this way:

{
            extend:'searchBuilder',
            className:'btn btn-sm btn-layer1 my-1',
            config: {
              columns: [3],
              preDefined: {
                criteria: [
                    {
                      data: 'Tags',
                      condition:'contains'
                    },
                 ],logic: 'AND'
              }
            }
          }

Replies

  • kthorngrenkthorngren Posts: 21,545Questions: 26Answers: 4,988

    Sounds like you want the default condition set to contains. Does this example do what you want?

    Kevin

  • NeurolinkedNeurolinked Posts: 2Questions: 0Answers: 0

    Unfortunately i already tried that one, it still expect me to pick the column.
    What i want to do is to pick automatically the tags column when i add a condition.
    As it's done like that it expect still the user to select a column, even when there is only one column to select from.

  • kthorngrenkthorngren Posts: 21,545Questions: 26Answers: 4,988

    I see. I don't see an option in the SearchBuilder docs. Maybe an option to sett he default column would be useful. @allan can comment on this. The only thing I can think of is to create an event handler for the SearchBuilder button that selects the desired column. AS an example copy this code into the console of the above linked example:

    $('#example').DataTable().table().container().getElementsByClassName('dtsb-add')[0].addEventListener("click", function(){
      let select = $('#example').DataTable().table().container().getElementsByClassName('dtsb-data')[0];
      select.value="1";
      select.dispatchEvent(new Event('change'));
    });
    

    With only one column set select.value="0";.

    @allan or others may have a better option for you.

    Kevin

Sign In or Register to comment.