material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Change value of row with action without losing filter states

Open samueldominguez opened this issue 6 years ago • 4 comments

Hello,

I want to change the value of a row with a table action. If I choose not to update the table, it won't reflect the change I've made to the table data, because it has not re-rendered. If I render again to update the data viewed by the user, then I lose the current filtering state. I know there is a defaultFilter value, so in theory I could capture the current filter values as state, and set them again with the next update. However, I don't know how I could retrieve the current filter states.

Is there a way to do this?

samueldominguez avatar Sep 03 '20 09:09 samueldominguez

Second this. I too am trying to find out where/how the current filter state is stored so that I can reference it for another purpose. Can anyone please advise? I haven't found any documentation on this here, in stackoverflow, or elsewhere - there's got to be a way right?

lbuscherX avatar Sep 28 '20 20:09 lbuscherX

#491 as patricekaufmann said https://github.com/mbrn/material-table/issues/491#issuecomment-541011677

let [columnObject] = useState({title: "col",field: "col"});
=>
<MaterialTable columns={ [ columnObject ] }/>

I use columns

const [ columns ] = useState([
  {
    title: "",
    field: "",
    lookup: {},
    defaultFilter: [""],
  },
]);
<MaterialTable
  columns={columns}
/>

is also ok, the filter states will not lose.

jiangtaozy avatar Oct 27 '20 08:10 jiangtaozy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jan 25 '21 11:01 stale[bot]

I haven't tested the proposed solution but guessing it probably works. Thanks @jiangtaozy

samueldominguez avatar Jan 27 '21 10:01 samueldominguez