Skip to content

Select dropdown with LIKE behaviour #867

Open
@nigellima

Description

@nigellima

Hello.

In my table, the first column is a combination of data that I pass a string with @ as separator and the format them with the formatter function as follow:

This is my column definition:

let projectFilter;
  columns = [{
       dataField: 'project',
       text: 'Project',
       filter: textFilter({
         options: fpsoOptions,
         getFilter(filter){
           projectFilter = filter;
         },
         style: { display: 'none' }
       }),
       sort: true,
       formatter: this.projectFormatter,
       headerStyle: (col, idx) => {
         return smHeaderStyle;
       },
     }, [..]

And this is the projectFormatter function:


projectFormatter = (cell, row) => {
    const values = cell.split('|');
    const fpsos = values[0].split('@');
    return (
      <div>
        {fpsos.map((pu, idx) => {
          const identity = pu.split(';')[0];
          const id = pu.split(';')[1];
          const separator = idx !== fpsos.length - 1 ? ", " : '';
          return (
            <Link to={`/view/${id}/fpso`}>{identity}{separator}</Link>
          )
        })}
        <br/>
        <span><b>{ values[1] }</b></span><br/>
      </div>
    );
  }

The filtering works fine when it is a text input filter. Now, I'm trying to do a custom select filter with a LIKE operator behaviour, which the selected value in the dropdown (fpso list) would be filtered as a substring of this column.

This is my onChange function that triggers the table filter, as shown in the documentation here. But I'm not sure how to get the like behaviour.


 const onChangeFilter = (e) => {
        projectFilter(e.target.value)
    }

I appreciate any clue/help. Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions