public function dispatch()
{
$view = $this->getActionController()->initView();
$params = $this->getRequest()->getParams();
if (empty($params['format'])) {
// render table
$view->iOptions = $this->iOptions;
$view->cols = $this->cols;
return;
}
// get data
$rows = array();
$handle = $this->handle;
$data = $this->dataSource->getData($params, $this->cols);
foreach ($data as $entity) {
$rows[] = $handle($entity);
}
// set data
$view->iTotalRecords = $this->dataSource->getCount();
$view->iTotalDisplayRecords = $this->dataSource->getCount($params, $this->cols);
$view->aaData = $rows;
$view->sEcho = !empty($params['sEcho']) ? $params['sEcho'] : 0;
}