grid-js / gridjs

Advanced table plugin
https://gridjs.io
MIT License
4.39k stars 240 forks source link

Server-side search no longer calls to search function #1411

Closed SaturnR closed 8 months ago

SaturnR commented 8 months ago

The search feature stopped working in the new 6.1.0 release. The old 6.0.6 version works well.

In my case, the function searchURL is never executed.


  function searchURL(prev, keyword){
    console.log(prev, keyword);
    return `${prev}${prev.includes("?")? "&": "?"}search=${keyword}`;
  }

  React.useEffect(() => {
    if (grid == null) {
      const data = null;

      var table_grid = new gridjs.Grid({
            columns: columns,
            sort: false,
            pagination: true,
            fixedHeader: true,
            search: true,
            resizable: true,
            data: data,
            search: {
              server: {
                url: (prev, keyword) => searchURL(prev, keyword)
              }
            },
            server: {
              url: url,
              then: (data) =>
                unpackData(data)
              ,
              total: (data) => data.count,
            },
            pagination: {
              limit: 10,
              server: {
                url: (prev, page, limit) =>
                  `${prev}${prev.includes("?")? "&": "?"}limit=${limit}&offset=${page * limit}`,
              },
            },
          });
        setGrid(table_grid);
        table_grid.render(wrapperRef.current);
    }else{
      grid.render(wrapperRef.current);
    }
  });
  return (<div ref={wrapperRef} />);
};

No additional errors or warnings from grid.js

vkresch commented 8 months ago

I noticed the same issue only in version 6.1.0 which was released yesterday (https://github.com/grid-js/gridjs/pull/1408). cc @afshinm

afshinm commented 8 months ago

@vkresch @SaturnR This is fixed now, please try https://github.com/grid-js/gridjs/releases/tag/6.1.1