Giter Site home page Giter Site logo

lenamax2355 / slicer-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from faghmie/slicer-js

0.0 0.0 0.0 1.07 MB

Create excel-like filters/slicers for your HTML tables on your website

Home Page: https://biznous.net

License: MIT License

JavaScript 49.29% HTML 26.03% CSS 24.69%

slicer-js's Introduction

Slicer-JS

Provide the Excel slicer capability to websites. Simple implementation to help filter table or datasets using visual feedback.

Slicer in action

See it in action

Visit my cloud-based business insights application demo.biznous.net to see how it is being used in production.

Dependencies

  • jQuery (3.4.1) - so I don't need to worry about cross browser issues LOL
  • jQuery-UI (1.12.1) - for resize and draggable (cause HTML5 drag-n-drop scares me)
  • Bootstrap (4.0.0) - mainly used for the style option
  • FontAwesome (5.10.0) - button icons on slicer title bar

Install

<link type="text/css" rel="stylesheet" href="../dist/css/slicer-js.min.css" />
<script type="text/javascript" src="../dist/js/slicer-js.min.js"></script>

Usage

<script type="application/javascript">
    document.addEventListener('DOMContentLoaded', function(){
        //BASIC CREATE
        (new Slicer())
                .attach({
                            container: $('#example'),
                            field: 'Position'})
                .make_editable();

        //ALL OPTIONS CREATE
        (new Slicer())
                .attach({
                            container: $('#example'),
                            dataset: null,
                            style: 'secondary',
                            title: 'Age of Staff', 
                            field: 'Age',
                            top: '100px',
                            left: '300px',
                            width: '180px',
                            height: '300px',
                            on_change: function(){
                                console.log('START save change to age')
                            },
                            on_before_change: function(){
                                console.log('STOP save change to age')
                            }
                        })
                .make_editable();
    });

</script>

Options

container

Optional

Only ommit this value (or set it to null) if you are providing the dataset value.

Container into which the slicer should be created. If no dataset is provided, it will assume the container is an HTML table and then convert it to a dataset.

field

Mandatory

This is the field whose unique list of value should be shown in the slicer

dataset

Optional

Default : null

Only omit this value if you are providing an HTML table in the container field.

Object representing the data to render into the slicer.

{
   name    : "unique-name",   //string value
   header  : [...],           //array representing the header row
   rows    : [[...]],         //array of arrays representing the data rows in the table
}

title

Optional

Default : When omited it will use the field value

Title to display for the slicer. When the title is omited it will use the field value.

width

Optional

Default : 400px

Width of slicer

height

Optional

Default : 200px

Height of slicer

top

Optional

Default : 200px

Absolute "top" position relative to the page

left

Optional

Default : 200px

Absolute "left" position relative to the page

style

Optional

Default : primary

This is a combination of the "default" bootstrap themes and some custom themes which is defined in the css files provided possible values are:

Bootstrap colors

  • light
  • primary
  • warning
  • danger

Custom colors

  • heritage-green
  • fresh-green
  • future-green
  • sky
  • sun
  • naartjie
  • cerise

on_change

Optional

Callback function after the user made a selection on the page

function(){
   console.log('call after user selected items on slicer');
}

on_before_change

Optional

Callback function BEFORE the user selection is applied to the table/dataset

function(){
   console.log('call made before selection is applied');
}

Related

This is one of the components used in the biznous.net platform

Licence

The javascript component slicer-js is released under the MIT license

slicer-js's People

Contributors

faghmie 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.