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.067 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started