Bancha 1: Usage in ExtJS and Sencha Touch

Note: This is the documentation for Bancha 1. You can find the current documentation here.

Using models

Bancha provides a simple interface to create models. These models get all fields, validations and associations and a fully configured proxy from the server.

You just have to use Bancha.onModelReady(‘User’, function() {...}) or Bancha.onModelReady([‘User’,’Article’, function() {...}) and Bancha does the rest!

Configuring stores

If you want to use a Bancha model for a store, simply create it like this:

Ext.create('Ext.data.Store', {
    model: Bancha.getModel('User')
});

Loading of data, pagination and remote sorting works out of the box.

Remote Filtering

Bancha will give each store by default to the option to filter on associations. For security reasons other filtering is by default prevented. If you want to expose filtering on other columns, just allow them before calling inside your controller method the pagination with:

$this->Paginator->setAllowedFilters(array(
'id','name','category','some_other_field'));

Usage Example:

var store = Ext.create('Ext.data.Store', {
    model: Bancha.getModel('User'),
    remoteFilter: true
});
store.filter('category','admin');
store.load();

Using exposed Controller Methods

Every controller method, which is marked as remotable can be accessed with:

Bancha.getStub('MyController').myMethod(param1, param2, callback);

For more see How to Expose Controller Methods.

Comments

Add a comment