Features
-
This is React Bootstrap Dynamic Table component.
-
This table component is a very Generic and Dynamic table component.
-
User can set the columns - how many column, he/she want to show(they can configure in header configuration)
-
User have to pass only Header Configuration and SourceData in json structure format.
-
Sort By Column
-
User can sort table data by column key in ascending or descending order.
-
Search
-
User can search data by passing searchQuerry
-
Just call the callback function onSearch in input field on onChange handler and pass search querry as parameter
-
eg: <input type="text" onChange={(e) => configuration.onSearch(e.target.value)} />
-
User can enable or disable search by column, make isSearchEnabled true or false in configuration column setting (eg. isSearchEnabled: true)
-
User can pass the action like Edit/ Delete to perform the action on each row.
-
User can change their table column width
-
User can change their table style on his/her choice
Install
First install react-bootstrap-dynamic-table using command
npm install react-bootstrap-dynamic-table --save
Import
After that import react-bootstrap-dynamic-table
;;;
After require fontawesome react-fontawesome
const Font = ;
How to use
And then use this table where you want on your page.
<ReactBootstrapDynamicTable ...userTableObj />
Pass userTableObj object as a props in **ReactBootstrapDynamicTable ** component.
// table object pass to table component const userTableObj = configuration: configuration // table configuration sourceData: tableDatadata // array Data // optional props - this will rerurn selected data // if you want checkbox configure showCheckbox: true in configuration and pass this callback function // usersList is selected data you can store in your var or state errorMessage: errorMessage //optional props - you can pass error messsage also if table have no data ;
###Note key should be same as data(array) key eg: id, name, email, mobile etc.
Configuration is a object which contains table header columns settings.
/* table header settings * Note: key should be same as data(array) key eg: id, name, email, mobile etc. */ const configuration setConfiguration = ;
Source Data - Array data
// table data const tableData setTableData = ;
Example
;;;; const Font = { /* table header settings * Note: key should be same as data(array) key eg: id, name, email, mobile etc. */ const configuration setConfiguration = ; // table data const tableData setTableData = ; // table object pass to table component const userTableObj = configuration: configuration sourceData: tableDatadata ; return <div className="App"> /* input box for search */ <form className="form-inline m-2"> <div className="form-group"> <input type="text" className="form-control form-control-sm" onChange= configuration placeholder="Search..." /> </div> <div className="form-group"> <span className="search-input-icon"><i className="fa fa-search"></i></span> </div> </form> /* Table component pass userTableObj as props */ <ReactBootstrapDynamicTable ...userTableObj /> </div> ;};
Table
Id | Name | Mobile | Action | |
---|---|---|---|---|
1 | Senthil R | 793744 | senthil@email.com | ... |
2 | Abinaya L | 895874 | abi@email.com | ... |
3 | Rahul | 569329 | rahul@email.com | ... |
4 | Amit | 798857 | amit@email.com | ... |
5 | Dheeraj | 974384 | dheeraj@email.com | ... |