phalcon-datatables icon indicating copy to clipboard operation
phalcon-datatables copied to clipboard

Added new feature: using model methods for table render with custom formatting.

Open mzf opened this issue 9 years ago • 7 comments

For existed issue #7

mzf avatar Feb 03 '16 17:02 mzf

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));
    }

mzf avatar Feb 04 '16 03:02 mzf

Is this work with fromResultSet() too ?

I don't think so!

alimo2 avatar Oct 19 '16 10:10 alimo2

@mzf i test it but i can't get anything! It dosn't work!

alimo2 avatar Oct 19 '16 11:10 alimo2

@alimo2 work only with builder

mzf avatar Oct 20 '16 03:10 mzf

@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!

alimo2 avatar Oct 22 '16 06:10 alimo2

Would you please fix this

alimo2 avatar Oct 22 '16 07:10 alimo2

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!

alimo2 avatar Oct 22 '16 08:10 alimo2