Docs
API
  • Controllers

    Controllers is the way to provide application architecture.
    It helps to divide application code along logical lines.
    It is possible to write code without controllers.
    Controllers are structured alternative to events.


    To start work with controller, it needs to define it over FancyGrid.defineController

    name

    String

    Control name.
    Must be unique.
    Use namespaces if needed: "App.myCotroller".

    params

    Object

    Params with handlers, functions and controls property.

    Controller with events

    Sample:

    
    FancyGrid.defineController('mycontrol', {
      onCellClick: function(grid, o){
        
      },
      onCellDBLClick: function(grid, o){
        
      }
    });
    
    var grid = new FancyGrid({
      ...
      events: [{
        cellclick: 'onCellClick'
      },{
        celldblclick: 'onCellDBLClick'
      }],
      controllers: ['mycontrol'],
      ...
    });
    

    Controls instead of events

    Sample:

    
    FancyGrid.defineController('mycontrol', {
      controls: [{
        event: 'cellclick',
        handler: 'onCellClick'
      },{
        event: 'celldblclick',
        handler: 'onCellDBLClick'
      }],
      onCellClick: function(grid, o){
        
      },
      onCellDBLClick: function(grid, o){
        
      }
    });
    
    var grid = new FancyGrid({
      ...
      controllers: ['mycontrol'],
      ...
    });
    

    Control selector

    Sample:

    
    FancyGrid.defineController('mycontrol', {
      controls: [{
        event: 'cellclick',
        selector: '.sign-minus',
        handler: 'onClickMinus'
      },{
        event: 'cellclick',
        selector: '.sign-plus',
        handler: 'onClickPlus'
      }],
      onClickMinus: function(grid, o){
        
      },
      onClickPlus: function(grid, o){
        
      },
    });
    
    var grid = new FancyGrid({
      ...
      controllers: ['mycontrol'],
      ...
    });
    

    List of controls properties

    event

    String

    Grid event name and dom event name.

    selector

    String

    Not required. Delegator(source element).

    handler

    Function

    Handler of event.