Code Monkey home page Code Monkey logo

tablesigniter's Introduction

TablesIgniter

Latest Stable Version Total Downloads License

Tableslgniter is an addins base on CodeIgniter4. It will help you use jQuery Datatables in server side mode.

If you want to get CodeIgniter3 version of Tableslgniter you can go to this git repository.

Visit the sample website and read user guide.

TablesIgniter 基於 CodeIgniter4 。它將可以幫助你在 使用 server side mode 中使用 jQuery Datatables。

如果你希望取得 CodeIgniter3 版本的 Tableslgniter 你可以前往這個 git儲存庫

造訪範例網站與使用指南

Install

Prerequisites

  1. CodeIgniter Framework 4.*
  2. Composer

Composer Install

composer require monken/tablesigniter

Use Library

Declare the following code in the controller that will use TablesIgniter.

use monken\TablesIgniter;

Quick Start

HTML

<table id="firstTable">
    <thead>
        <tr>
            <th>id</th>
            <th>title</th>
            <th>date</th>
        </tr>
    </thead>
</table>

JavaScript

$('#firstTable').DataTable({
    "aoColumnDefs": [{ 
        "bSortable": false,
        "aTargets": [ 0,1,2 ] 
    }],
    "order":[],
    "serverSide":true,
    "searching": false,
    "lengthChange":false,
    "ajax":{
        url:"<?=base_url('home/firstTable')?>",
        type:'POST'
    }
});

Controller

public function firstTable(){
    $model = new HomeModel();
    $table = new TablesIgniter();
    $table->setTable($model->noticeTable())
          ->setOutput(["id","title","date"]);
    return $table->getDatatable();
}
  1. Calling the "setTable()" method must pass in a Query Builder object. TablesIgniter relies on the database query content defined by this object. This object is usually declared in the Model.

  2. When calling the "setOutput()" method, the array must be passed in. The order of the array will affect the order of the data presented by DataTables. The definition of the string must be the same as the field name of the result queried by "setTable()".

  3. Calling "getDatatable()" will get the json string that meets the requirements of jQuery DataTables.

Model

public function noticeTable(){
    $builder = $this->db->table("news");
    return $builder;
}

You are free to use all the methods of Query Builder to meet all your requirements for database query. Finally, you must return the objects generated by Query Builder.

tablesigniter's People

Contributors

monkenwu avatar pooleasee avatar

Watchers

James Cloos 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.