Jump to content


set_relation_n_n where on list view


  • Please log in to reply
5 replies to this topic

#1 carperolm

carperolm

    Member

  • Members
  • PipPip
  • 14 posts

Posted 01 March 2016 - 06:19 PM

Hi there,
 
I'm getting mad with this issue.
 
I have a n:n relation 
 
$where = "department_id = 1";
$crud->set_relation_n_n('departments','exp_dep','departments','exp_id','department_id','name, null, $where);
 
I would like to filter the listing view with a condition over a field in departments table departments.department_id
 
Everything works ok on edit and add views but is not working on listing state. I've been searching on forum but I didn't found any help.
 
If I use 
 
$crud->where('department_id',1);  I get a mysql error:
 
Unknown column 'department_id' in 'where clause'

 

Could anyone help me?

 

 

Thanks in advance.

 
 

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

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

Posted 02 March 2016 - 04:59 AM

Try icing along the table name of the department_id .. it may not belong to the same table on which the primary query is being fired. It may help you accordingly.



#3 carperolm

carperolm

    Member

  • Members
  • PipPip
  • 14 posts

Posted 02 March 2016 - 06:19 PM

Hi Amit, Thanks for your fast answer. I've tried that before post the topic. Doesn't work either.



#4 Amit Shah

Amit Shah

    grocery CRUD Master

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

Posted 03 March 2016 - 09:00 AM

can u share the whole piece of code -- looking at the same, may be able to give some solution..!!



#5 carperolm

carperolm

    Member

  • Members
  • PipPip
  • 14 posts

Posted 03 March 2016 - 11:28 AM

Hi Amit,

 

This is the basic code and it's working for the add and edit views, but not for the list view. I want to filter by departamento_id

$crud = new grocery_CRUD(); 
$crud->set_table('expedientes');
$crud->set_subject('Expedientes');
$where = "departamento_id = 1";
$crud->set_relation_n_n('departamentos','exped_depar','departamentos','expediente_id','departamento_id','name', null, $where);
$output = $crud->render();

Thanks



#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/






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users