Socket
Socket
Sign inDemoInstall

sails-hook-datatable

Package Overview
Dependencies
16
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sails-hook-datatable

A sails hook for working with jquery datatable


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

sails-hook-datatable

A sails hook for working with Jquery datatables.

Install

npm i sails-hook-datatable --save

Support

This hook supports jquery DataTables 1.10+. If your working with a legacy version, see https://datatables.net/manual/server-side#Legacy for congiuration.

Usage

Send a GET or POST to /datatable/:model to use

NOTE: Always set column.data as showing in example below as sails.js Always respond with an array of object [{"name":"foo"}, {"name":"bar"}]] not literals like [["boy","foo"], ["girl","bar"]]. You can also set column.data = country.state.city where country is the column name. This would be handle well by both this hook and datatable.

//Example where *account* is the model name


//ajax
$('#example').DataTable( {
    serverSide: true,
    ajax: {
        url: '/datatable/account',
        type: 'POST'
    },
    "columns": [
            { "data": "name" },
            { "data": "country.state"}
        ]
} );

//response
{
    "draw": 1,
    "recordsTotal": 57,
    "recordsFiltered": 57,
    "data": [
        {name: 'Damian', country: {state: "New york"}},
        {name: 'Sam', country: {state: "Benin"}},
        {name: 'Robophil', country: {state: "London"}},
        {name: 'Ovie', country: {state: "Paris"}}
    ]
}

To view attributes in a model, send a GET to /datatable/column-names/:model to fetch the attributes for that model. See response below

{ columns: [
    'id', 'firstname', 'lastname'
]}

Issues or Missing implementation

Create an issue to mention a bug or feature request. Fixed something? Send a PR

Liscence

MIT

Keywords

FAQs

Last updated on 13 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc