npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@velitsol/inertia-vue-datatable

v0.0.2

Published

Datatable in inertia JS

Downloads

1

Readme

Inertia js datatable for Laravel

npm version License

This package is written in vue 3 with the support of Inertia js for Laravel projects.

Features

  • Global search
  • Sorting column
  • Pagination (support for Eloquent)

Compatibility

  • Vue 3
  • Inertia.js
  • Tailwind CSS
  • Laravel 9

Limitations

  • Not responsive for mobile display

Installation

You can install the package via npm:

npm install @velitsol/inertia-vue-datatable

Usage

Register in app.js

In your app.js file, you can register the component globally to make it available across your entire Vue.js application.

import { InertiaDataTable } from "@velitsol/inertia-vue-datatable";

createApp(App).component("InertiaDataTable", InertiaDataTable).mount("#app");

By registering the component globally, you can use it in any Vue component template without the need for importing it specifically.

Register locally in a Vue component

If you prefer to register the component locally in a specific Vue component, you can do so as follows:

import { InertiaDataTable } from "@velitsol/inertia-vue-datatable";

export default {
  components: {
    InertiaDataTable,
  },
  // ...
};

Props

| Prop | Type | Default | Description | | --------- | -------- | ------------------------- | ---------------------------------- | | records | object | null | Paginated response from Laravel | | columns | object | null | Heading cloumns of table | | actions | array | ['view','edit','delete] | Actions of table | | _route | string | null | Route prop is required for actions |

Slots

| Slot | Return | Description | | ---------- | ----------------- | ------------------- | | heading | column object | Column heading | | row | record object | Table row | | column | record object | Table column | | action | record object | Table action column | | pagination | links object | Table pagination | | empty | No Data Available | Table empty |

Examples

General

<script>
import { reactive } from "vue";

export default {

  props: ["events"],
  setup(props) {

    /**
     *  key should database field name
     *  heading is column heading in datatable
     *  sortable represents a column should sortable or not
     *  format callback : it returns single
     *  _record callback : it returns row
     */
    const dataTableColumns = reactive([
     { key: "name", heading: "event", sortable: 1 },
      {
        key: "start_date",
        heading: "start_date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      },
      {
        key: "end_date",
        heading: "End Date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      {
        key: "published_app",
        heading: "Published App",
        sortable: 1,
      },
      {
        key: "published_web",
        heading: "Published Web",
        sortable: 0,
      },
    ]);

    return { dataTableColumns };
  },
};
</script>

<template>
     <inertia-data-table
          :records="events"
          :columns="dataTableColumns"
          :_route="'events'"
          :actions="['view', 'edit', 'delete']">
      </inertia-data-table>
</template>

Heading slot

<script>
import { reactive } from "vue";

export default {

  props: ["events"],
  setup(props) {

    /**
     *  key should database field name
     *  heading is column heading in datatable
     *  sortable represents a column should sortable or not
     *  format callback : it returns single
     *  _record callback : it returns row
     */
    const dataTableColumns = reactive([
     { key: "name", heading: "event", sortable: 1 },
      {
        key: "start_date",
        heading: "start_date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      },
      {
        key: "end_date",
        heading: "End Date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      {
        key: "published_app",
        heading: "Published App",
        sortable: 1,
      },
      {
        key: "published_web",
        heading: "Published Web",
        sortable: 0,
      },
    ]);

    return { dataTableColumns };
  },
};
</script>

<template>
     <inertia-data-table
          :records="events"
          :columns="dataTableColumns"
          :_route="'events'"
          :actions="['view', 'edit', 'delete']">

             /**
             *  Syntax : #heading-column_key
             *  Return : It returns column object
             *  Description : You can add any icon with column heading.
             */

            <template #heading-name="{ column }"> Event Name </template>
            <template #heading-start_date="{ column }">  Event Start Date </template>

      </inertia-data-table>
</template>

Column slot

<script>
import { reactive } from "vue";

export default {

  props: ["events"],
  setup(props) {

    /**
     *  key should database field name
     *  heading is column heading in datatable
     *  sortable represents a column should sortable or not
     *  format callback : it returns single
     *  _record callback : it returns row
     */
    const dataTableColumns = reactive([
     { key: "name", heading: "event", sortable: 1 },
      {
        key: "start_date",
        heading: "start_date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      },
      {
        key: "end_date",
        heading: "End Date",
        sortable: 1,
        format: function (v) {
          return moment(v).format("MM/DD/YYYY h:mm:ss A");
        },
      {
        key: "published_app",
        heading: "Published App",
        sortable: 1,
      },
      {
        key: "published_web",
        heading: "Published Web",
        sortable: 0,
      },
    ]);

    return { dataTableColumns };
  },
};
</script>

<template>
     <inertia-data-table
          :records="events"
          :columns="dataTableColumns"
          :_route="'events'"
          :actions="['view', 'edit', 'delete']">

             /**
             *  Syntax : #heading-column_key
             *  Return : It returns column object
             *  Description : You can add any icon with column heading.
             */

            <template #heading-name="{ column }"> Event Name </template>
            <template #heading-start_date="{ column }">  Event Start Date </template>

      </inertia-data-table>
</template>

License

This project is licensed under the MIT License. Make sure to mention the license type and provide a link to the full license file.

Credits

If your package includes code or assets from other projects, provide proper attribution or credits to the original authors or sources.

Support

If users encounter any issues or have questions, provide instructions on how they can reach out for support. This can be through a GitHub issue tracker, email, or any other communication channel.