Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Filters again - nested table

Filters again - nested table 20 May 2013 10:15 #7212

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Hi,

Again about filters. I have a nested table (backend collection view) and I want to filter it by parent_id, in the sense that I want to retrive the tree that has parent_id as root.

I have already used the query to filter the data in the front-end, using a custom function, (where parent_id is a menu parameter) but now, trying to obtain that as filter results from prepareQuery, I'm having troubles.

Basically, I need to compare (NOT TO JOIN) the "elements" table with itself, then I have to use this code (inside elements model, prepareQuery function):
//WHERE - FILTER : Parent id
if($this->getState('filter.parent_id') != null){			
$this->addWhere('a.lft between b.lft and b.rgt');
$this->addWhere('b.id = '. (int)$this->getState('filter.parent_id'));}

So, I have added this line before the select:
$query->from('#__manta_elements AS b');

Now, the filter works as expected -> I select the value from the drop-down, the query is correctly called and the values shown correctly.
BUT now the default view does not work anymore: any element appears in the grid 12 times (!) and if I check the executed queries I find a lot of select a.* repeated.
If I comment the additional "$query->from" then everything goes back to normality but obviously the filter does not work anymore...

I think I can workaround this by filtering-modifying the array of values inside default_grid.php before it's used...but still...this is not how this is supposed to go...

How can I add a "$query->from" to prepareQuery withouth messing up all the results ?!?!

Thanks

Elena
The administrator has disabled public write access.
Time to create page: 0.063 seconds

Get Started