Giter Site home page Giter Site logo

kalipsotable's Introduction

KalipsoTable

Pure JS data table library.

Usage

Just include the script and style file in the page and set the options block.

<head>
  <link rel="stylesheet" type="text/css" href="kalipso.table.css">
  <script src="kalipso.table.js">
</head>

Localization

If you want to use it with an external language, you must include the relevant language file before including the resources.

<head>
  <script src="l10n/[lang].js">
  ...
</head>

Prepare

First, let's set the DOM element for which the table will be created.

<div id="usersTable"></div>

You can trigger the KalipsoTable with the following setting block.

  const options = {
    selector: "#usersTable",
    language: "tr",
    // server: true, // SERVER-SIDE
    // source: 'http://webaddress.com/list',
    server: false, // CLIENT-SIDE
    source: [
      {id: 1, u_name: 'alonzo', name: 'Alonzo Forza', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.05.05', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 2, u_name: 'carlb', name: 'Carl Ben', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.05.06', updated: '2022.05.05', status: 'passive', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 3, u_name: 'dan14edward', name: 'Dan Edward', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.05.08', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 4, u_name: 'hankfrank', name: 'Frank Hank', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.05.09', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 5, u_name: 'thomopeter22', name: 'Thomas Peter', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.08.22', updated: '2022.05.05', status: 'passive', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 6, u_name: 'time', name: 'Edward Tim', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2021.04.13', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 7, u_name: 'wm', name: 'Walter Monte', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2021.09.10', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 8, u_name: 'george.c', name: 'George Corte', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.07.12', updated: '2022.05.05', status: 'deleted', action: ''},
      {id: 9, u_name: 'hi.ben', name: 'Ben Thomas', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2020.05.24', updated: '2022.05.05', status: 'active', action: '<button class="btn btn-danger btn-sm">Delete</button>'},
      {id: 10, u_name: 'otto_dan', name: 'Dan Otto', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.03.28', updated: '2022.05.05', status: 'deleted', action: ''},
      {id: 11, u_name: 'kotto_dan', name: 'Kenau Dan Otto', email: '[email protected]', birth_date: '1996.08.14', role: 'admin', created: '2022.03.28', updated: '2022.05.05', status: 'deleted', action: ''}
    ],
    columns: [ 
      {
        "searchable": {
          "type": "number",
          "min": 1,
          "max": 999
        },
        "orderable": true,
        "title": "#",
        "key": "id"
      },
      {
        "searchable": {
          "type": "text",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Kullanıcı Adı",
        "key": "u_name"
      },
      {
        "searchable": {
          "type": "text",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Ad",
        "key": "name"
      },
      {
        "searchable": {
          "type": "text",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Eposta Adresi",
        "key": "email"
      },
      {
        "searchable": {
          "type": "date",
        },
        "orderable": true,
        "title": "Doğum Tarihi",
        "key": "birth_date"
      },
      {
        "searchable": {
          "type": "text",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Rol",
        "key": "role"
      },
      {
        "searchable": {
          "type": "date",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Eklenme",
        "key": "created"
      },
      {
        "searchable": {
          "type": "date",
          "maxlength": 50
        },
        "orderable": true,
        "title": "Güncellenme",
        "key": "updated"
      },
      {
        "searchable": {
          "type": "select",
          "datas": [
            {"value": 'active', "name": "Aktif"},
            {"value": 'passive', "name": "Pasif"},
            {"value": 'deleted', "name": "Silinmiş"}
          ],
        },
        "orderable": true,
        "title": "Durum",
        "key": "status"
      },
      {
        "searchable": false,
        "orderable": false,
        "title": "İşlem",
        "key": "action"
      }
    ],
    customize: {
      tableWrapClass: "table-responsive",
      tableClass: "table table-bordered",
      inputClass: "form-control form-control-sm",
      selectClass: "form-control form-control-sm",
    },
    tableHeader: {
      searchBar: true
    },
    tableFooter: {
      visible: true,
      searchBar: true
    }
  };
  const table = new KalipsoTable(options);

API

Reset

If you want to reset the data table, you can use the reset() method.

table.reset();

Server-side and KalipsoTable PHP Class

Requests made on the server side are thrown with the GET method. The version information of KalipsoTable is carried in the header with the definition of X-KALIPSOTABLE. You can use the KalipsoTable class written in PHP for server-side data manipulation and output.

Server-side Request

  • per_page: ex. 5 || 10 || 100
  • order: ex. id,desc (with comma)
  • full_search: ex. Alex
  • search: ex: {"name": "Alex", "status", "active"} (as url encoded json)

Server-side Response

  • current_page: 1
  • filtered_count: 10
  • record_count: 325
  • records: [{id: "207", u_name: "jack-joe_25415", name: "Joe Jack", email: "[email protected]",…},…]
  • total_page: 33

kalipsotable's People

Contributors

halillusion avatar

Watchers

 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.