Giter VIP home page Giter VIP logo

kodatatable's Introduction

#KODataTable This is a screaming fast,reactive dynamic datatable viewmodel/template for Knockout with search, header sorting and item selection.

Homepage & Demo

http://mikeallisononline.com/Projects/KODataTable

Install

(bower): bower install ko-datatable
(optional) bower install jtablescroll

(npm): npm install ko-datatable
(optional) npm install jtablescroll

(nuget): Package-Install KODataTable
(optional): Package-Install jTableScroll

##Add-on Modules http://mikeallisononline.com/Projects/jTableScroll

https://github.com/rgeerts/KODataTable-dragable

License

MIT

Copyright

2013 Mike Allison

Example Table

<div id="kodt">
    <div>
        <input type="text" data-bind="value: searchText, valueUpdate: 'afterkeydown'" />
        <select data-bind="value: selectedColumn, options: columns"></select>
        <button data-bind="click: search">Search</button>
    </div>
    <div>
        <table class="jTableScroll">
            <thead>
                <tr data-bind="foreach: columns">
                    <th data-bind="text: $data,
                        click: function() { $parent.sort($index()) }" style="cursor: pointer"></th>
                </tr>
            </thead>
            <tbody data-bind="foreach: currentRows">
                <tr data-bind="foreach: $parent.columns,
                    click: function () { $root.selectRow($data); },
                    css: { 'success': $root.selectedRow() == $data }">
                    <td data-bind="text: $parent[$data]" style="cursor: pointer"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div>
        <button data-bind="click: firstPage">First</button>
        <button data-bind="click: prevPage">Prev</button>
        Page <span data-bind="text: currentPage() + 1"></span> of <span data-bind="text: pageCount"></span>
        <button data-bind="click: nextPage">Next</button>
        <button data-bind="click: lastPage">Last</button>
    </div>
</div>

Javascript

<script src="KODataTable-1.0.2.js"></script>
<script src="jquery.jTableScroll-1.6.0.js"></script>
<script>
    var TableDataVM = new KODataTable({ options });
    ko.applyBindings(TableDataVM, document.getElementById("kodt"));
</script>

Options (JSON object)

{
    columns: (Array[String]) List of columns - ex: ["Id","Name","Description"]
    rows: (Array[JSON Object]) Row data - ex: [{Id:1, Name: "Mike Allison", Description: "Desc 1"}]
    searchText: (string)(optional) initial search text
    currentPage: (integer)(optional) current starting page
    pageSize: (integer)(optional) number of rows to display (default: 20)
    tableHeight: (integer)(optional) height of result table if scrolling
    tableWidth: (integer)(optional) width of result table if scrolling
    autoSearch: (boolean)(optional) enable auto-search (default: true)
    firstFn: (function)(optional) function to perform on first page event
    nextFn: (function)(optional) function to perform on next page event
    prevFn: (function)(optional) function to perform on prev page event
    lastFn: (function)(optional) function to perform on last page event
    searchFn: (function)(optional) function to perform on search click event
    sortFn: (function)(optional) sort event function
    selectFn: (function)(optional) select event function
}

##Additional columns, rows, and selectedRow can all be set or accessed dynamically through your viewmodel. This can easily attached to external datasources such as webservices

TableDataVM.rows(yourNewRowData);

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.