Add custom elements to React Table pagination-top - reactjs

I'm looking to conditionally add a button to my React Table, and for it to display to the right of the row size selector in the PaginationTop section.
The project is currently using react-table 6.9.2.
Currently the table simply uses showPaginationTop as an argument in the ReactTable component, resulting in this header after some custom css:
With a custom element displaying, I'm looking for it to appear as:
Does anyone know if this is possible without changing the react-table source for PaginationTop?

My bad, this can be done with component overriding as mentioned in the documentation here:
https://github.com/tannerlinsley/react-table/tree/v6#component-overrides
For my solution this involved making a new component and setting it as the default:
Object.assign(ReactTableDefaults, {
PaginationComponent: Pagination,
...

Related

How can I implement react-markdown within a react-table cell?

In the app I am currently working on, there is a "Description" column which I would like to have rich text. This would be stored in my database in Markdown format. Is there anyway when using react-table to have cells contain content in another component, in this case so the content could be rendered by react-markdown?
Before implementing react-table I was able to parse the markdown in the description cells with <td><ReactMarkdown>{item.description}</ReactMarkdown></td>, but I'm not seeing a way to accomplish this with react-table.
This is the code in question: https://github.com/TechValleyCenterOfGravity/STUFF/blob/main/src/App.js
I missed a capital C - Cell: props => <ReactMarkdown>{ props.value }</ReactMarkdown> did the trick

Use form.getFieldValue to add logic between field without warning

I have a Ant Design 4.x.x Form element without multiple Form.Item. I need to implement some logic involving form items' values, for example disabling a field if another one's value equals something, or recalculate select options when a text input changes.
To do so, I create the form using Form.useForm() and use form.getFieldValue() in my functional component body and / or in the returned JSX, like so :
It is working as I expect to, but at startup, getFieldValue usages throw annoying
index.js:1 Warning: Instance created by `useForm` is not connect to any Form element. Forget to pass `form` prop?
I found that Form functions cannot be used before rendering, and the problem also occured when displaying a form in a Modal like stated in the docs.
So I feel that I'm missing something on how to correctly add custom logic between fields, or doing some calculation involving fields values in component body.
What would be a correct approach to do this ?
Try adding getContainer={false}, to your modal this will work for you.

I want keep the text in the filer section after a Material-Table rendering

Im filtering using remote mode in the Material-Table component, but after each filtered, and Material-Table rendered, it delete the text or selection from the filter section.
So I would like to understand if there is a way in the table to keep this values, because it is necessary that the user have reference of what he is seeing in the table.
Im using the last version, 1.32
This is the component https://github.com/mbrn/material-table
Best Regards and thanks in advance for your time in my case
Move your columns object to a state.
Make a state var,
const [materialColumn] = useState([{title: "Name",field: "name"}]);
Then on your material table
<MaterialTable
columns={materialColumnObj}
/>
This will solve the problem. The filter text will stay. Cheers!

Integrate mui-datatable with admin-on-rest

How to integrate mui-datatable with admin-on-rest?
Need the following options in the list view :
move around ordering of columns
show/hide columns
change the number of rows for display
print preview of table
Mui-datatable has these features. According to admin-on-rest documentation, we can use custom Datagrid. Can anyone explain how to do it?
Say you are making a custom-datagrid component 'MyIterator'. This component has to just make use two props that will 'auto-magically' be available to the child of 'List' component. One prop is ids and another is data.
The ids prop is an array of id of currently displayable data-items. And the data is an object containing the data for all the items displayable.
Something like this should do the part of making a custom-datagrid -
const MyIterator = ({ids, data}) => ids.map(id=><div key={id}><span>Label</span><span>{data[id].label}</span></div>)
Above example presumed the data-item object to have a property of 'label'.
And this is how a custom-datagrid can be made.

How to return data on selection of multiple rows in React material ui table?

/*
Details :
I am looking for a way to implement table in such a way that
I can add or remove the data on click or selection of row.
Also can we use native js events in the material - ui
Also, if any library is there, please share as soon as possible.
*/
Map over the table row data and add a prop for this.handleEdit.bind(this, data.id) and this.handleRemove.bind(this, data.id). Then in those functions, use the id to make an api call to update or delete the row.

Resources