Giter Site home page Giter Site logo

jsongridify's Introduction

JSON Gridify

JSON Gridify is a library that generates table from raw data. Even nested json array and object can be converted. Note: It uses JQuery.

General

Main function is

GRIDIFY.convertToTable(container, data, options)

Parameters

  • container: the DOM element that table is written on
  • data: the rawdata that must be a valid JSON
  • options: the js object data that is used to generate table properly. It waits for some attributes: Options

Options

  • title: tables title
  • buttons: a boolean value that shows helper buttons while true and vice versa
  • tableClass: add class to the table
  • labels: Labels

Example:

options:{
  title: "Example Table",
  buttons: true,
  tableClass: "my-table",
  labels: {} // It will be shown on Labels part
}

Labels

  • label name: the name that refer to each attribute of real data
    • tag: appears as table header-th of the related attribute (if there is no tag, attribute name comes from raw data is used as th)
    • modifier: converts data to a dom element or a modified text node
    • class: adds class to the related th and td elements
    • css: adds css style to the related th and td elements

Example:

let exampleRawData = [{
  "id": 1,
  "name": "Jhon Doe",
  "gender": "M",
  "military": {
    "status": "D",
    "exempt": {
      "status": "F",
      "date": "2020-10-10"
    }
  },
  "isMaried": true
}];

let options = {
  labels: {
    id: {
      tag: "ID",
      classd: "d-none",
    },
    name: {
      tag: "Full Name",
      css: {
        color: "red",
      }
    },
    gender: {
      tag: "Gender",
      modifier: {
        M: "Male",
        F: "Female",
      }
    },
    military: { // nested 
      tag: "Militarial Status",
      status: {
        tag: "Status",
        modifier: {
          D: "Done",
          E: "Exempt",
        }
      },
      exempt: {
        tag: "Exempt",
        status: {
          tag: "Status",
          modifier: {
            I: "Infinite",
            E: "Finite",
          }
        },
        date: {
          tag: "Exempt Date"
        }
      },
      isMaried: {
        tag: "Are You Married?",
        modifier: {
          true: "<input type='checkbox' checked disabled><label hidden>Married</label>",
          false: "<input type='checkbox' disabled><label hidden>Single</label>",
        },
      }
    }
  }
};

jsongridify's People

Contributors

abdurrahman-akkus avatar

Stargazers

 avatar Ozan 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.