0.1.0 • Published 2 years ago

@hanzoz/v-grid-on-steroids v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Revogrid on steroids

build status coverage report

-> Live demo in the Appstore <-

How to use

Install with NPM:

npm i @basf/v-grid-on-steroids --save

DataTable

<template>
  <div>
    <VGridOnSteroids
      border
      :range="true"
      :columns="columns"
      :source="source"
    />
  </div>
</template>

<script>
import VGridOnSteroids from '@hanzoz/v-grid-on-steroids'

export default {
  name: 'App',
  components: {
    VGridOnSteroids
  },
  data () {
    return {
      columns: [
        {
          prop: 'name',
          name: 'Name',
          size: 150,
        },
        {
          prop: 'gender',
          name: 'Gender',
          size: 150,
        }
      ],
      source: [
        {
          name: 'Luke Skywalker',
          gender: '',
        },
        {
          name: '',
          gender: '',
        },
      ],
    }
  }
}
</script>

DataTable with Async Function & custom editor

  • Provide a new config on a column called asyncFunc, which takes a text as input and returns a promise as output that resolves to an object with a text property and a state property (good or bad)
  • Moreover, you may provide a custom editor to the column
<template>
  <div>
    <VGridOnSteroids
      border
      :range="true"
      :columns="columns"
      :source="source"
    />
  </div>
</template>

<script>
import VGridOnSteroids from '@hanzoz/v-grid-on-steroids'
import { VGridVueEditor } from '@hanzoz/vue-datagrid'
import customComponent from './components/customComponent'

export default {
  name: 'App',
  components: {
    VGridOnSteroids
  },
  data () {
    const customEditor = Vue.extend({ ...customComponent })

    return {
      columns: [
        {
          prop: 'name',
          name: 'Name',
          size: 150,
          asyncFunc: (val) =>
            axios
              .get(`https://swapi.dev/api/people/?search=${val}`)
              .then((r) => {
                return {
                  text: r.data.results[0].name,
                  state: 'good',
                }
              }),
        },
        {
          prop: 'count',
          name: 'Count',
          size: 200,
          editor: VGridVueEditor(customEditor),
        },
      ],
      source: [
        {
          user: 'Luke Skywalker',
          strain: '',
        },
        {
          user: '',
          strain: '',
        },
      ],
    }
  }
}
</script>

Props

Props

NameTypeDefaultDescription
columnsarray[]DataTable column’s value
sourcearray[]DataTable source's data
borderbooleanfalseInclude border for the DataTable
heightstring200Set height for the DataTable

Columns

NameTypeDefaultDescription
propstring''Column’s prop value
namestring''Column's header name
sizenumber-Column's width
asyncFuncfunction-Takes a text as input and returns a promise as output that resolves to an object with a text property and a state property (good or bad)
editorfunction-Set custom editor for the column's cell using VGridVueEditor(customEditor)

Async Function

When the api call return data, you need to return state property as (good or bad) for the icon to be there or else there won't be any icon showing. A loading state will return when the api call triggered.

columns: [
  {
   ...
    asyncFunc: (val) =>
      axios
        .get(`https://swapi.dev/api/people/?search=${val}`)
        .then((r) => {
          return {
            text: r.data.results[0].name,
            state: 'good',
          }
        }),
    ...
  },

DataTable cell editor

You can use your own custom editor or use the preset component as the editor of the cell

Bundle component

coming soon...

Custom component

For custom component, you need to imnport the component and configure as below

<script>
...
import { VGridVueEditor } from '@hanzoz/vue-datagrid'
import sampleComponent from './components/sampleComponent'

export default {
  ...
  data () {
    const customEditor = Vue.extend({ ...sampleComponent })
    return {
      columns: [
        ...
        {
          ...
          editor: VGridVueEditor(customEditor),
        },
        ...
      ],
      ...
  }
}
</script>
0.1.0

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago