question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select dropdown with LIKE behaviour

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AllenFangcommented, Mar 24, 2019

BTW, if you are implement the custom filter, the default comparator will be LIKE, here is a custom filter example.

1reaction
AllenFangcommented, Mar 24, 2019

@nigellima so far the select filter use EQ as default comparator and it can not be change/configure. I will enhance this when I have time, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dropdown - Semantic UI
A dropdown allows a user to select a value from a series of options.
Read more >
Divs dropdown to behave like select or combo - Stack Overflow
I need different functionality, when click to Option element to change the value in the Select div and nothing more, same behaviour like...
Read more >
UI cheat sheet: dropdown field - UX Collective
While not technically a dropdown, a multiple select menu is an alternative to consider. Unlike a dropdown, they are open from the start...
Read more >
behavior:dropdown-select - Sciter
size=integer - number of visible elements in the dropdown list. Note: height of the select element can be overriden by CSS. name="name" -...
Read more >
Dropdown - Multiselect - Carbon Design System
Dropdowns present a list of options from which a user can select one option, or several. A selected option can represent a value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found