⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Where clauses on relation table in list view?



Kobus

Kobus
  • profile picture
  • Member

Posted 22 October 2014 - 15:02 PM

Hi all,

 

Hope you guys can help me.

 

I have two tables that need to be linked: 'user' and 'dealer'. The relation table is 'user_dealer'.

I found using $crud->set_relation_n_n() works well for edit and add screens to restrict which records are edited and added, like this:

$crud->set_relation_n_n('Dealers', 'user_dealer', 'dealer', 'user_id', 'dealer_id', 'dealer', null, array('id' => $this->session->userdata('dealer_id')));

But for some reason, this does not work for the LIST grid.

I tried $crud->where() but this does not work, as it does not have the column from the relation table there.

 

Can anybody help, please? I also posted this on Stack Overflow, so hope I get this resolved soon.

 

Thanks,

 

Kobus

 


Kobus

Kobus
  • profile picture
  • Member

Posted 22 October 2014 - 17:34 PM

As a side note: I have not been receiving any comments on my posts in the last few months. Is GC stagnant?


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 23 October 2014 - 09:25 AM

GC is not stagnant.. have a look @ all the replies thats going on .. and then comment on the same.

 

As for your solution - the set_relation ... will have where clause executed only for the list generation and not the data representation. For data - it just maps to the value in the relation table and displays it...

If you wana restrict it.. even in listing you need to do the same using $crud->where ... here is where u set the criteria for allowing / disallowing the data to be displayed up or not.

 

Happy GCing :)


carperolm

carperolm
  • profile picture
  • Member

Posted 25 February 2016 - 15:50 PM

Kobus,

 

I'm trying to solve this out. Did you get a solution for this?

 

Could someone provide me an example? I can't find any example on the forum

 

Thanks in advance.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 02 March 2016 - 05:07 AM

Kobus, can you share you complete code / function so someone can analyze the same and share you where exactly and what u need to change?


carperolm

carperolm
  • profile picture
  • Member

Posted 03 March 2016 - 12:24 PM

I found the solution here:

/topic/2367-pre-filtering-data/