Jump to content


Where clauses on relation table in list view?

where relation

  • Please log in to reply
5 replies to this topic

#1 Kobus

Kobus

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationSouth Africa

Posted 22 October 2014 - 03: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 Myburgh
Managing Director: Impero Consulting
http://www.impero.co.za
+27 82 043 8488


#2 Kobus

Kobus

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationSouth Africa

Posted 22 October 2014 - 05:34 PM

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


--------------------
Kobus Myburgh
Managing Director: Impero Consulting
http://www.impero.co.za
+27 82 043 8488


#3 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)



#4 carperolm

carperolm

    Member

  • Members
  • PipPip
  • 14 posts

Posted 25 February 2016 - 03: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.



#5 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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?



#6 carperolm

carperolm

    Member

  • Members
  • PipPip
  • 14 posts

Posted 03 March 2016 - 12:24 PM

I found the solution here:

http://www.grocerycr...filtering-data/







Also tagged with one or more of these keywords: where, relation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users