Remote Sorting & Filtering

Remote Sorting

By default Sencha Touch/Ext JS sorts records locally, but it provides a config to filter on the server: remoteSort

Bancha will automatically translate the sorting parameters into the default format for the CakePHP PaginatorComponent and so everything will work out of the box without any configuration needed.

Remote Filtering

By default Sencha Touch/Ext JS filters records locally, but it provides a config to filter on the server: remoteFilter

Bancha will send this config to the server and automatically translates the filter parameters into the CakePHP find conditions, which are understood by the PaginatorComponent.

You can set the allowed filters to one of the following:

  • 'all'
    Please choose wisely, defining 'all' could lead to potencial security issues since hackers could expose more data then expected with standard MySQL-like attacks. E.g. filtering by password with regex or filtering other hidden information.
  • 'associations' (default)
    This exposes only fields where there is an association defined in the model, so for Article belongsTo User filtering by user_id is allowed.
  • array('fieldname1', 'fieldname2')
    This will be transformed to the option below.
  • array('User.field1', 'User.field2')
    You can specifically define which fields you want to allow filtering upon.
  • 'none'
    No filtering is allowed. This will be transformed to an empty array.

Bancha will by default allow Ext JS/Sencha Touch 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'));

Comments

Add a comment