Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

smart-table-crud

CircleCI

Add CRUD behavior to a smart-table

Installation

npm

npm install smart-table-crud --save

yarn

yarn add smart-table-crud

Usage

Compose with your smart table

import table from 'smart-table-core'
import crud from 'smart-table-crud'

const t = table({data=[/*some data*/]}, crud);

//your smart-table exposes now new methods from the crud API  

update(index, newVal)

Process a full replace of an item and refresh the table based on its actual state (sort, filter, etc)

//assuming row 42 is {firstName:'blah', lastName:'woot'}
t.update(42, {firstName:'new firstname'});
//now row 42 is {firstName:'new firstname'}

patch(index, patialNewValue)

Process a partial update of an item without refreshing the table (ideal for inline editing)

//assuming row 42 is {firstName:'blah', lastName:'woot'}
t.update(42, {firstName:'new firstname'});
//now row 42 is {firstName:'new firstname', lastName:'woot'}

remove(index)

Remove an item from the table and refresh the table

t.remove(42);

insert(newValue, [indexToInsert])

Insert a new value in the table at provided index (as first item otherwise) and refresh the table

t.insert({firstName:'new firstname'}); //insert as new first item of the table
t.insert({firstName:'new firstname'}, 42); //insert as 42th item

get(index)

Get the reference of the item at index (or undefined)

const itemAt42 = t.get(42);

Contributing

test

npm test

or

yarn test

issues

Only bugs coming with a running example

About

Add CRUD behavior to a smart-table

Resources

License

Packages

No packages published