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.

Request : Allow user provided search text, shown columns, sorting, etc.

See original GitHub issue

First, thank you for making this amazing datatable module. As I’m using material-ui for the first time, I couldn’t be happier with such an amazing tool that automatically uses the theme of my application and offers so many features to pick from.

That being said, I love your callback functions that inform us about what the current search query is, which filters are applied, etc. I decided to use those callbacks to implement a “persistent” config in my application, so that the datatable can automatically render using the persistent config if the table is ever unmounted / mounted back in a short period of time.

Expected Behavior

To be able to render the DataTable by providing the searchText, displayedColumns, etc.

This feature would make it easy to “persist” every datatable settings on componentWillUnmount (in cookies, for example) then to load them back the next time the DataTable is mounted.

Current Behavior

Currently, we are able to provide the “filterList” array, which makes us able to save the user filters and load them back anytime we want (great !), but other options (like the search query or the current sorting parameters) cannot seem to be provided as props.

Example of an expected behavior :

 constructor(props) {
   super(props);
   // Retrieve the persisted settings and set them to the state
 }

 componentWillUnmount() {
   // Retrieve the settings from the state and persist them (cookies, local storage, wherever)
 }

 handleWhateverFunction() {
   // Update the current state with the latest changes
 }

 render() {
    const { data } = this.props;
    const { filtersConfig, searchQuery, sortingConfig, displayedColumns } = this.state;
    return (
      <DataTable
        columns={config.columns}
        data={data}
        options={{
          displayColumns: displayedColumns,
          filter: true,
          filterList: filtersConfig,
          searchText: searchQuery,
          selectableRows: false,
          textLabels: config.labels,
          print: false,
          responsive: 'scroll',
          onDisplayedColumnsChange: this.handleDisplayedColumnsChanged,
          onFilterChange: this.handleFilterChange,
          onRowClick: this.handleRowPress,
          onSearchChange: this.handleSearchChange,
          onSortChange: this.handleSortChange,
          sortingList: sortingConfig
        }}
      />
    );
  }

Your Environment

Tech Version
Material-UI 3.4.0
MUI-datatables 2.0.0-beta-38"
React 16.4.1
browser Chrome

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
gregnbcommented, Nov 15, 2018

I’m trying to find the time to redo the filterList along side many other options that would be used to rehydrate the table. It’ll be a breaking change in the near future but bear with me

1reaction
letsspeakcommented, Feb 8, 2019

I also need this default searchText option, for After page reloading. On my strategy with Server query,

  1. Capture MUIDataTable search events, save searchText on Web Browser URL and fetch data from Server
  2. When Users reload page, re-build State from URL and fetch data from Server
  3. But I cannot set MUIDataTable’s initial searchText state
  4. So when Users click Next Page button, Server query does’t includes searchText

Yes, I can avoid this problem via comparing State’s (from URL) searchText vs MUIDataTable’s searchText before Server query. But I hope I can set MUIDataTable’s searchText initially.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Order by Clause overview and examples
This article will cover the SQL ORDER BY clause including syntax, usage scenarios to sort out results in a Select statement.
Read more >
Filtering and Sorting Data - Using Microsoft Excel
To use a filter,. Go to the Home ribbon, click the arrow below the Sort & Filtering icon in the Editing group and...
Read more >
SQL for ordering by number - 1,2,3,4 etc instead of 1,10,11,12
I assume your column type is STRING (CHAR, VARCHAR, etc) and sorting procedure is ... outside of ORDER BY, so that is why...
Read more >
How to Sort Data in Excel using VBA (A Step-by-Step Guide)
Suppose you have a single column without header (as shown below). Data for sorting with VBA - without headers single column. You can...
Read more >
Video: Sort, filter, summarize, and calculate your PivotTable data
Training: You can analyze PivotTable data in many ways, including sorting to quickly see trends. ... Show different calculations in PivotTable value fields....
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