tigrang / cakephp-datatable

JQuery DataTable plugin server-side processing component for CakePHP
47 stars 29 forks source link

Is there any way to use containable behavior ? #71

Open nitish-mca opened 8 years ago

nitish-mca commented 8 years ago

Hi, Is there anyway to use containable behavior in datatable query ?

tigrang commented 8 years ago

Yes, just add the contain key to the configuration in the component. Depending on the type of relation you may not be able to sort on the associated columns (a second query may be used where a join is needed). You'll need to force a join using joins or re-binding the association in a different way.

vermarenu commented 8 years ago

Hi, According to above suggestion i added code like : 'contain' => array('table name'),'joins' => array( array( 'table' => 'table name', 'alias' => 'table alias', 'foreignKey' => false, 'conditions' => [], 'type' => 'inner', ), ),

rule for this "table name" is not define in that particular model. but nothing happen. please correct where i am wrong ? is this necessary to define rule in model ? Also if i want to bind/unbind model for this plug-in then where to write code.

nitish-mca commented 8 years ago

I couldn't find the way for fetch data with recursive level 2. I had tried contain as well as join queries. I also try it with setting recursive 2

tigrang commented 8 years ago

@nitish-mca can you share some code. Also, take a look at http://mark-story.com/posts/view/using-bindmodel-to-get-to-deep-relations

If you can get the queries that are generated that would help. Thanks.