Git Product home page Git Product logo

jviz-list's Introduction

editable-list

A module to build an editable list

Install

Use jviz to install this module on your project:

jviz install jviz-editable-list

Options

data

An array that will be used as the data to be displayed on the list. Each element of the array must be an object where each key is a cell on the list.

jviz.modules.editableList({
  data: [
    { name: 'John', age: 26, city: 'San Francisco', country: 'EEUU' },
    { name: 'Susan', age: 24, city: 'New York', country: 'EEUU' },
    { name: 'Steve', age: 30, city: 'Tokyo', country: 'Japan' }
  ]
});

columns

An array with the columns to display on the list.

jviz.modules.editableList({
  columns: [
    { key: 'name' , editable: false }
  ]
});

Each element of the array must be an object with the following keys:

  • key: (mandatory) a string with the key of the data which value will be displayed on this column.
  • editable: a boolean to set if the data of this column is editable or not. Default value: true.
  • helper: a string that will be displayed on the bottom of the input at the edit mode.

info

An object with the information about the column info. The column info is the first cell of each element of the list, and provides information about the element.

jviz.modules.editableList({
  info:
  {
    //Enable the column info
    visible: true,

    //Set the title for each element
    title: function(el, index){ return el.title; },

    //Set the detail of the element
    detail: function(el, index){ return 'This is the element ' + index + ' of my list.'; }
  }
});

This option accepts the following keys:

visible

A boolean to set if the info cell is visible or not. The default value is false.

title

A string or function with the title of the element. If a function si passed, this will be called with the following arguments:

  • el: an object with the data of the actual element.
  • index: an integer with the order of the element on the list.

detail

(Optionally) A string or function with the detail of the element. If a function is passed, this will be called with the same arguments of the title key.

API

cancel(index)

Cancel the edition of one element of the list.

//Edit the first element
list.edit(0);

//Cancel the edition of the first element and restore the values
list.cancel(0);

This method accepts the following arguments:

  • index: the number of the element of the list.

delete(index)

Delete an element from the list.

//Delete the first element of the list
list.delete(0);

This method accepts the following arguments:

  • index: the number of the element of the list that will be deleted.

edit(index)

Edit the content of an element of the list.

//Set an element of the list as editable
list.edit(0);

This method accepts the following arguments:

  • index: the number of the element of the list.

save(index, obj)

Update an element of the list.

list.save(0, { key1: 'value1', key2: 'value2' });

This method accepts the following arguments:

  • index: the number of the element of the list.
  • obj: an object with the data that will be updated on the element of the list.

jviz-list's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.