2017 © Pedro Peláez
 

library mks-smart-table

Laravel Server-side processing for angular-smart-table

image

mikelmi/mks-smart-table

Laravel Server-side processing for angular-smart-table

  • Saturday, March 4, 2017
  • by mikelmi
  • Repository
  • 1 Watchers
  • 1 Stars
  • 49 Installations
  • JavaScript
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 26 % Grown

The README.md

Server side processing for angular-smart-table for Laravel 5

This package provides services for server-side processing data for angular-smart-table, (*1)

Installation

  1. Install via composer, (*2)

        composer require mikelmi/mks-theme:dev-master
    
  2. Add the service provider in config/app.php, to providers:, (*3)

        Mikelmi\SmartTable\Providers\SmartTableServiceProvider::class,
    
  3. Publish assets, (*4)

        php artisan vendor:publish --provider="Mikelmi\SmartTable\Providers\SmartTableServiceProvider"
    

Usage

Server side

Create route for handling smart-table-request., (*5)

Inside the route:, (*6)

  1. Create data source. It can be Query Builder (Eloquent/Database) or Collection, (*7)

    //Query Builder
    $source = \App\User::select(['id', 'name', 'email', 'created_at']);
    
    //or Collection
    $source = collect([
        ['id' => '1', 'name' => 'John Smith'],
        ['id' => '2', 'name' => 'Mister X'],
        //...
    ]);
    
  2. Create SmartTable Engine instance, (*8)

    $engine = app(\Mikelmi\SmartTable\SmartTable::class)->make($source);
    
    //optionaly set columns for general search
    $engine->setSearchColumns(['name', 'email'])
    
  3. Apply request, (*9)

    $engine->apply();
    
    //optionaly apply advanced method for your source, e.g. default sorting
    $engine->orderBy('created_at', 'desc');
    
  4. Return the response, (*10)

    return $engine->response();
    

Client side

  1. Include javascript file. This package ships with three js files:, (*11)

    • mks-smart-table.js - contains only base functionality, without any libraries
    • mks-smart-table-st.js - includes angular-smart-table
    • mks-smart-table-full.js - includes all required dependencies (angular 1.x and angular-smart-table)

    E.g. (in your template):, (*12)

       ...
       <script src="path/to/angular.js"></script>
       <script src="{{asset('vendor/mikelmi/mks-smart-table/js/mks-smart-table-st.js')}}"></script>
       <!-- Your another js -->
    </body>
    
  2. Add mks-smart-table dependency to your angular application. E.g.:, (*13)

    var app = angular.module('myApp', ['mks-smart-table']);
    
  3. Init controller TableCtrl, (*14)

    <div ng-controller="TableCtrl as grid" ng-init="grid.init('{{url('/url/to/handler')}}')">
    
  4. Output the table, (*15)

    <table class="table" st-pipe="grid.pipeServer" st-table="grid.rows">
       <tbody>
           <tr ng-repeat="row in grid.rows">
               <td>{[{row.id}]}</td>
               <td>{[{row.name}]}</td>
               <td>{[{row.email}]}</td>
               <td>{[{row.created_at}]}</td>
           </tr>
       </tbody>
    </table>
    
  5. Advanced features:, (*16)

    • Global search, (*17)

      You can add some input outside the table for filtering the results, (*18)

      <input type="search" ng-model="gridQuery">
      

      And then add mst-watch-query directive to the table head, (*19)

      <thead mst-watch-query="gridQuery">
      
    • Select rows, (*20)

        <tbody>
            <tr ng-repeat="row in grid.rows">
                <td mst-select-row="row"></td>
      
    • 'Select All' checkbox, (*21)

      <thead>
          <tr>
              <th mst-select-all-rows="grid.rows"> </th>
      
    • TableCtrl functions, (*22)

      • removeLocalRow(row) - remove row without server-side action
      • removeRow(row, url, confirmText) - remove row after server-side action by url
      • removeSelected(url, confirmText) - remove selected rows after server-side action by url
      • getSelected() - get selected rows
      • updateRow(row, url, confirmText) - post row by url and update it with returned data
      • updateSelected(url, confirmText) - same as updateRow but works with array of selected rows

Additional Info

There is no styles for the tables in this package. You can Twitter Bootstrap for styling it., (*23)

Here https://github.com/mikelmi/mks-smart-table/tree/master/example you can check the example of usage this package., (*24)

For more information about client-side implementation please visit the angular-smart-table site - https://lorenzofox3.github.io/smart-table-website/, (*25)

The Versions

04/03 2017

dev-master

9999999-dev

Laravel Server-side processing for angular-smart-table

  Sources   Download

MIT

The Requires

 

by mike_lmi

laravel datagrid angular mks smart-table

04/03 2017

v2.1.1

2.1.1.0

Laravel Server-side processing for angular-smart-table

  Sources   Download

MIT

The Requires

 

by mike_lmi

laravel datagrid angular mks smart-table

21/02 2017

v2.1

2.1.0.0

Laravel Server-side processing for angular-smart-table

  Sources   Download

MIT

The Requires

 

by mike_lmi

laravel datagrid angular mks smart-table

27/01 2017

2.0.x-dev

2.0.9999999.9999999-dev

Laravel Server-side processing for angular Smart-Table module

  Sources   Download

MIT

The Requires

 

by mike_lmi

27/01 2017

v2.0

2.0.0.0

Laravel Server-side processing for angular Smart-Table module

  Sources   Download

MIT

The Requires

 

by mike_lmi

25/08 2016

v1.0

1.0.0.0

Laravel Server-side processing for angular Smart-Table module

  Sources   Download

MIT

The Requires

 

by mike_lmi

15/08 2016

1.0.x-dev

1.0.9999999.9999999-dev

Laravel Server-side processing for angular Smart-Table module

  Sources   Download

MIT

The Requires

 

by mike_lmi