1.1.6 • Published 5 years ago

@venoid/admin-datatable v1.1.6

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

Venoid Admin Datatable Component

npm npm bundle size (scoped)

Datatable component for your administration provides you good options how to load your data from an api to a table with an pagination.

screenshot-example

Props

PropsTypeDefault
table-columnsArrayundefinedArray of objects with options
on-api-callFunctionundefinedFunction which is resolving your api call. Should return promise! Example here
current-pageNumber1Number of the current page (if paginated is true)
per-page-optionsArray{value: '5', label: 5}, {value: '10', label: 10}, {value: '15', label: 15}, {value: '20', label: 20}Define your own select box with per page options (if paginated is true)

table-column options

{
  type: 'string' // Enum['id', 'number', 'string ],
  label: 'Name'  // String,
  field: (row) => row.name //Render function for data,
  width: '60' // String
}

on-api-call function

  • This function is called on component create and everytime some action in datatable happens (click on a new page, selec per page etc.)
  • In parameter is an object with a currentPage and perPageCount. It indicates current page and count of data displayed on a page. Additional properties will be added soon...
// your on-api-call function
getBooks({ currentPage }) {
  return new Promise(async (resolve, reject) => { // return promise, which will be resolved inside the component
    try {
      const { data } = await axios.get("https://my-json-server.typicode.com/dmitrijt9/book-api-mock/books") // make your request (axios is just for example, you can call also call graphql server using apollo etc.)
      resolve({ // in resolve function return your data (array) and total count of the data to make pagination work properly
        data,
        total: data.length
      })
    } catch (e) {
      reject(e) // what happens when request fails
    }
  })
}

Demo

To see demo run a project:

  1. Install npm dependencies
  2. Run with npm run serve / yarn serve
1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago