list.js - 快速给实现列表、表格的排序搜索等功能

3,025 阅读1分钟
原文链接: www.listjs.com

[ { feature: "sort" }, { feature: "search" }, { feature: "filter" } ]

Look here! This is an example of what List.js can do

Sort features

  • Search Search through all items.
  • Sort Sort lists by value that you choose.
  • Filter Write your own filter functions.

Add List.js-functionality to existing list

HTML


Sort features
  • Search Search through all items.
  • Sort Sort lists by value that you choose.
  • Filter Write your own filter functions.
  • Add Add items on the fly.
  • Get Get item based on value.
  • Update Update items as you go.
  • Remove Remove items whenever you feel like.

JavaScript


var options = {
    valueNames: [ 'feature', 'description' ]
};

var featureList = new List('example-list', options);

Add List.js to list, and then add new items

HTML


Sort features
  • Search Search through all items.
  • Sort Sort lists by value that you choose.
  • Filter Write your own filter functions.

JavaScript


var options = {
    valueNames: [ 'feature', 'description' ]
};

var values = [
    { feature: 'Add', description:'Add items on the fly.' }
    , { feature: 'Get', description:'Get item based on value.' }
    , { feature: 'Update', description:'Update items as you go.' }
];

var featureList = new List('example-list', options, values);

var newFeature = {
    feature: 'Remove'
    , description:'Remove items whenever you feel like.'
};

featureList.add(newFeature);