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

@sulzanoks/vue-datatable

v0.2.2

Published

DatatableCard is a custom Vue.js component designed to provide a flexible and customizable datatable for your web applications. It is built from scratch, inspired by the Bootstrap datatable, but with added features to support Vue.js style links and row se

Downloads

21

Readme

DatatableCard Component

DatatableCard is a custom Vue.js component designed to provide a flexible and customizable datatable for your web applications. It is built from scratch, inspired by the Bootstrap datatable, but with added features to support Vue.js style links and row selection.

Installation

You can install the DatatableCard component using npm:

npm install @sulzanoks/vue-datatable

Usage

To use the DatatableCard component in your Vue.js application, you can import it and include it in your component's template. Here's an example of how to use it:

<template>
  <div>
    <datatable-card
      :card-title="cardTitle"
      :columns="columns"
      :url="dataUrl"
    >
    </datatable-card>
  </div>
</template>

<script>
import DatatableCard from '@sulzanoks/vue-datatable';
import '@sulzanoks/vue-datatable/dist/style.css';

export default {
  components: {
    DatatableCard,
  },
  data() {
    return {
      cardTitle: 'My Datatable',
      columns: [
        // Define your datatable columns here
        // Example: { data: 'id', name: 'ID', sortable: true, searchable: true }
      ],
      dataUrl: '/api/data', // Replace with your data endpoint URL
    };
  },
};
</script>

Props

The DatatableCard component accepts the following props:

  • cardTitle (String): The title for the datatable card.
  • clickable-rows (Boolean, optional, default: false): Set to true to enable row-click event.
  • columns (Array): An array of column objects defining the datatable columns.
    • data (String): The key to access the data for this column in the API response.
    • displayName (String): The display name or label for this column.
    • name (String): The unique name or identifier for this column.
    • searchable (Boolean, optional, default: true): Set to false to disable searching for this column.
    • sortable (Boolean, optional, default: true): Set to false to disable sorting for this column.
    • visible (Boolean, optional, default: true): Set to false to remove column from table.
    • width (String, optional): Set solumn to width specified css param.
    • linkParams (Object, optional): Defines link parameters for generating Vue.js style links.
      • name (String): The name of the Vue.js route to navigate to when clicking the link.
      • resourceIds (Array): An array of resource IDs to use in generating the link. Replace with actual resource IDs.
      • query (Object, optional): object of attributes to include in link query params
  • url (String): The URL for fetching datatable data.
  • selectableRows (Boolean): Set to true to enable row selection. For now only works if you have a, id column in your data set.
  • order (Array): The initial column sorting order. example: [{ column: 0, dir: 'asc' }]
  • advancedSearch (Boolean): Set to true to enable advanced search, which generates an individual search input for each searchable column.
  • loadDataOnInit (Boolean): Set to true to load data when the component is initialized.
  • cardIconStyle (String, optional, default: 'card-header-primary'. There are no other options): The CSS class to apply to the card's header for icon styling.
  • cardIcon (String, optional, default: null): The name of an icon from Google Icons to display in the card's header. Provide the icon name without any additional markup, such as <i> tags. For example, if you want to use the "account_circle" icon, set this prop to 'account_circle'. If not specified, no icon will be displayed in the card's header.
  • cardClasses (String, optional, default: null): Additional CSS classes to apply to the card.
  • createLink (String, optional, default: null): A link or URL to navigate to when clicking a "Create" button or link within the card.
  • requestQueryParams (Object, optional): additional request query parameters to include when loading data from server.
  • actions (Array, optional): Array of action objects defining action buttons for each row.
    • emit (String, required): name of event to emit upon click
    • icon (String, optional): The name of an icon from Google Icons to display inside button.
    • label (String, optional): Text to display inside button.
    • class (String, optional): CSS class to apply to button.

Internal Methods

These methods are meant to be used by component internally, but maybe you can find use for them

  • toggleSearch(): Toggle the search input.
  • clearSearch(): Clear the search bar and reload data.
  • setAdvancedSearchFilters(): Set advanced search filters based in input element values and reload data.
  • loadData(): Load datatable data.
  • initColumnSettings(): Initialize column settings.
  • setPageLength(length): Set the number of rows per page and reload data.
  • setPage(page): Set the current page and reload data.
  • setSearchTerm(): Set the full text search term for basic search on all columns and reload data.
  • setSorting(index): Set the sorting order for a column and reload data.
  • generateLink(linkParams, row): Generate a link based on parameters and row data.
  • selectAllRows(): Select or deselect all rows.
  • clearSelectedRows(): Clear the selected rows.

Methods

  • getSelectedRows(): Returns array of selected rows
  • filterColumns(params): Filter columns based on parameters and reload data.
    this.$refs.myDataTable.filterColumns([
        {
            name: 'serial_number',
            value: this.uniqueId,
        },
        {
            name: 'product_name',
            value: this.productName,
        }
    ]);
  • refresh(): Clears all sorting and filters, reloads or clears data based on loadDataOnInit prop.

Events

  • row-click: Emitted when row is click if clickable-rows prop is set to true. The event payload contains the clicked row data.

Compatibility

This component is designed to work with Laravel's yajra/laravel-datatables-oracle. It may work with other packages that use a similar input/output structure, but it has not been tested extensively with other packages.

Please make sure that your Laravel backend and the API endpoints are configured to work with this component.

License

This DatatableCard component is open-source software licensed under the MIT License. See the LICENSE file for more information.