gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

check enter press for MUIDataTable search input #1183

Open RaedShihab opened 4 years ago

RaedShihab commented 4 years ago

I'm dealing with MuiDataTable and i want to check enter press after adding search keywords inside the search text field. It is easy if we thinking about JavaScript ways, but the problem is I don't have access to search filed because it is built-in inside MuiDataTable.

// First checking for search action:

onTableChange: (action, tableState) => { console.log(action, tableState); switch (action) { case "search": console.log(action, tableState.searchText.charCodeAt()); break; } 'tableState.searchText.charCodeAt()' give me all aharacter code except Enter which is 13, Please help me guys

Expected Behavior

Current Behavior

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Your Environment

Tech Version
Material-UI
MUI-datatables
React
browser
etc
gabrielliwerant commented 4 years ago

Hello @RaedShihab. Can you explain what you mean by "inter press?" The first thing I would recommend you try, regardless, is the customSearch option which will allow you to intercept values on the way to the onChange function in the internal search field. If you need full access to the search, you can provide your own via a custom render. See the customize-search-render example for more information about how to do that.

wdh2100 commented 4 years ago
<div keyPress={onKeyPress}>
   <MUIDataTable
     title={"Employee List"}
     data={data}
     columns={columns}
     options={options}
   />
</div>