serviceplus-table
v0.1.3
Published
A reusable Table component for React
Readme
Service Plus Table
This is a Reusable Table Component with adavanced features.
The Table can be used as a Display table as well as an Action table
Hero features
- Controlled as well as Uncontrolled Pagination.
- Dynamic Sorting of columns.
- Global Search.
- Column Pinning - Pin columns to the right/left.
- Pass customStyles.
Usage
function Component() {
const [data, setData] = useState([]);
useEffect(() => {
const fetchData = async () => {
const response = await fetch("http://localhost:3000/test");
const result = await response.json();
setData(result);
};
fetchData();
}, []);
const handleAction = (action, rowData) => {
console.log(`Action: ${action}`, rowData);
};
const actions = ["allow", "reject"];
return (
<Table apiData={data} actions={actions} onAction={handleAction} check />
);
}Props accepted by the Table
- apiData - the data to be shown
- actions - If the table is an action table,then the actions will be inherited.
- onAction - handler for the action
- check - to make it a multicheck
- customStyles -
const defaultStyles = {
header: {
bg: "bg-slate-100",
text: "text-black",
border: "border",
},
body: {
bg: "bg-white",
text: "text-black",
border: "border",
},
};- pinning - to enable pinning of columns
