1.0.25 • Published 3 years ago

react-form-data-table v1.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Form Data Table

Features

  • Supports search string, records per page and pagination
  • Dynamic form elements to manipulate and save your data
  • UX available with light and dark theme
  • Adaptive for tablet and mobile viewports
  • Ajax put, post, update etc.. can be configured.
  • Row element onChange event, to update changes in row data, using dynamic form elements
  • Clone your custom data to data table
  • Show tooltip for elements
  • Configure Footer total with tailor made requirements
  • Configure pagination as you wish
  • Add a custom class name to change data table style. (Note:) This table is styled using display: grid with grid-template-columns

A Demo is always awesome

https://bharani-palani.github.io/react-form-data-table

Usage

<ReactFormDataTable
  data={[
    {id: 10000, name: "John", age: 21, salary: 50000},
    {id: 10003, name: "Woo", age: 28, salary: 60000}
    ...
  ]}
/>

Props

PropertyTypeDefaultSample
dataArray Refer Data Table
TableAliasRowsArray ID, Name, Age, Salary
showTotalArray salary
rowElementsArray Refer rowElements table
insertCloneDataArray {id: 10002, name: "Woo", age: 31, salary: 70000}
showTooltipForArray name
apiInstanceObjectRefer below table
defaultValuesObject{ }{age: "21"}
configObject{ }Refer Config table
classNameStringmy-custom-table
defaultValuesObject{ }{ age: 21 } Note: value will be added to element during adding rows in table
cellWidthString12rem20rem or 200px
themeStringlightlight or dark
onTableUpdate()functionCallback after table form is updated
insertCloneDataArray Clone your custom data to the top of your table.Refer Data Table

Data Table

Config sample

See https://www.w3schools.com/jsref/jsref_tolocalestring.asp for locale, currency and maxDecimal settings

Note:

  • currency can be USD, INR etc..
  • currentPage can be "first" or "last"

rowElements

ValueRender elementTypeDescription
textbox<input />StringText box to enter strings
number<input />StringText box to enter numbers
textarea<textarea />StringText area to enter paragraphs
checkbox<button />String+ and - buttons to add or remove. Note: Should always be in the first position in array of objects. See to that the values are unique to update values accordingly. Watch Demo
radio<input type="radio" />ObjectRefer radio sample below
multiChoice<PreDefined />ObjectRefer multiChoice sample below
date<PreDefined />ObjectDrop down date picker. Ex: new Date()
dateTime<PreDefined />ObjectDrop down date and time picker. Ex: new Date()

radio sample

multiChoice sample

Note:

  • If value is string("Mobile"), single select drop down is rendered.
  • If value is array("Mobile", "Email"), multi select select drop down is rendered. Array can be empty.
  • "searchable" key is default to true, which helps to search values from the list. To disable search functionality, you can set it to false. This feaure is only for multi select select drop.

apiInstance

We use Axios for xmlHttpRequest()

PropertyTypeSample
TableStringEmployeeMySqlTable
baseURLStringhttps://myapiservices.com
headersObject{ Authorization: MySecretHashKey }
ajaxApiUrlString/V1/updateEmployeeInformation
payloadKeyNameStringpostData putData payload etc..
ajaxTypeStringput post update etc..
onAjaxCallBackFunction(data) => showMessage(data)
ajaxButtonNameStringSave
onReFetchDataFunction Only success callback(data) => reRenderTableFromApi(data)

You like my work?

Contribute to cheer me up more open source..