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 Fancy.defineControl
name
StringControl name.
Must be unique.
Use namespaces if needed: "App.myCotroller".
params
ObjectParams with handlers, functions and controls property.
Controller with events
Sample:
Fancy.defineControl('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:
Fancy.defineControl('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:
Fancy.defineControl('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'],
...
});
Sample Cell Button
Sample Basic Controller
List of controls properties
event
StringGrid event name and dom event name.
selector
StringNot required. Delegator(source element).
handler
FunctionHandler of event.