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

This is what you call a component builder. I was able to master using this in a very short time and the resulting component works like a charm. Not just a basic component builder but a fully working component builder with forms fields tables all ready to go. You can make the list and item views to display in the front and back end. Also there is a great forum just starting to evolve and I'm sure this will grow very rapidly when you all realise how good this tool is.
Kevin (JED)

         

Get Started