cnizzardini / cakephp-datatable

CakePHP Component for interoperability between CakePHP 2.x and jQuery DataTables plugin.
62 stars 47 forks source link

Containable Not filtering #34

Open spacebiscuit opened 8 years ago

spacebiscuit commented 8 years ago

I'm using the branch release that supposedly supports Containable.

When I search to filter my table doesn't crash but the rows do not filter so it seems there is a bug.

$this->paginate = [
        'contains' => ['Product'],
                'fields' => [
                    'Variation.id','Variation.sku','tVariation.stock_level',
                    'Product.title'
                ],
 ];

$this->DataTable->mDataProp = true;
$this->set('response', $this->DataTable->getResponse());
$this->set('_serialize','response');
cnizzardini commented 8 years ago

There likely is a bug. I stopped development on this nearly 2 years ago and have no plans to support it in the future. You are welcome to commit a fix or become project owner if you are actively using this plugin. I have hopes at my new job that I can port this over to Cake 3 within the next year as we reboot our CRM, but no promises.

fr0z3nfyr commented 7 years ago

@spacebiscuit I don't see any issue with the plugin code for your issue. I did notice a problem in your code. Containable behavior must be used with key contain instead of contains in your code. Also, I put additional pagination settings into $this->Paginator->settings. So your code should be

$this->Paginator->settings = [
        'contain' => ['Product'],      // Note: "contain" - valid; "contains" - invalid
                'fields' => [
                    'Variation.id','Variation.sku','tVariation.stock_level',
                    'Product.title'
                ],
 ];

$this->DataTable->mDataProp = true;
$this->set('response', $this->DataTable->getResponse());
$this->set('_serialize','response');