Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.160 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started