phalcon-datatables
phalcon-datatables copied to clipboard
Added new feature: using model methods for table render with custom formatting.
For existed issue #7
Usage example:
$builder = $this->getDI()->get('modelsManager')
->createBuilder()
// если нужны коллбеки, то не использовать!
//->columns('id, name, email, status, created_at')
->from('Phalcon\UserPlugin\Models\User\User');
$columns = [
'id', 'name', 'email', 'status', ['created_at' => ['tableCreatedAt' => ['d.m.Y H:i']]]
];
$dataTables = new \DataTables\DataTable();
$dataTables->fromBuilder($builder, $columns)->sendResponse();
In User model
public function tableCreatedAt($format = 'd.m.Y H:i:s')
{
return date($format, strtotime($this->created_at));
}
Is this work with fromResultSet()
too ?
I don't think so!
@mzf i test it but i can't get anything! It dosn't work!
@alimo2 work only with builder
@mzf if we have a join & custom format method is in joint table model, what should i do ?
when using Join
, columns are not selected in result!
Would you please fix this
I think the problem is with join
itself!
when using join but dont mention columns, few of them are in result but not all!
using * in columns don't work either!