zepernick / Codeigniter-DataTables

CodeIgniter Library For Ajax Server Side DataTables 1.10 >
MIT License
94 stars 95 forks source link

Problem with data when using joinArray() #7

Closed ErvinLlojku closed 9 years ago

ErvinLlojku commented 9 years ago

Hello,

I have a problem with the data i get when joining tables. For example i have section table with this attributes id,name,title,created_at And the table Entries id,name,title,section_id

In the table i want to show id | sectionName | EntrieName

but in the entrieName Column i get the name of the section

This happens for other attributes that have the same name in the db like (title).

public function appendToSelectStr() { return null; } public function fromTableStr() { return 'subcategories s'; } public function joinArray(){ return array( 'categories c' => 's.category_id = c.id', 'sections sec' => 's.section_id = sec.id', ); } public function whereClauseArray(){ return null; }

I am using CI3.

Thanks.

zepernick commented 9 years ago

@ErvinLlojku, add the table alias as part of the data attribute name in the DataTables columns array.

data: "e.title" as an example. Just make sure that is corresponds with a table alias you have specified in the fromTableStr or the joinArray