⚠ 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

Flexigrid:Seaching will search whole table and disregard where function of GC



mavershim

mavershim
  • profile picture
  • Member

Posted 28 April 2012 - 02:35 AM

Hi,

I dont know if someone experience this. On my controller I filter the table using the where function of GC. but when I used the search (flexigrid theme) it will ignore the filter table and search the whole table.

lherlaar

lherlaar
  • profile picture
  • Member

Posted 28 April 2012 - 10:34 AM

Hi,

I can confirm this behavior and even some additional issues. Have a look at the following screenshots.

Here's the contents of my table:

[attachment=148:allrecords.png]

Now I add the following line of code to my controller:

$this->grocery_crud->where('cursuscode', 'TESTCOURSE');

This will lead to the following contents in the flexigrid:

[attachment=153:singlefilter.png]

So far so good.

But now I search for 'MYCOURSE' in all fields. I then get:

[attachment=154:singlefilterwithsearch.png]

This is exactly the problem you are describing: flexigrid search seems to disregards the WHERE clause.

However, the problem doesn't stop there. I now add another line of code to my contoller

$this->grocery_crud->or_where('cursuscode', 'MYCOURSE');

So, the query should now contain "WHERE cursuscode = 'TESTCOURSE' OR cursuscode = 'MYCOURSE'. This will lead to the following contents in the flexigrid:

[attachment=149:doublefilter.png]

This is as expected. So far so good.

But now I do some more searches, first for 'TESTCOURSE':

[attachment=150:doublefilterwithsearch1.png]

This is not as expected; TESTCOURSE2 should not be there, according to the WHERE clause.

And let's now search for 'MYCOURSE':

[attachment=151:doublefilterwithsearch2.png]

This is not as expected; TESTCOURSE should not be there, according to the flexigrid search condition.

And finally, let's search for 'ANOTHERCOURSE':

[attachment=152:doublefilterwithsearch3.png]

This is again not as expected; ANOTHERCOURSE should not be there, according to the WHERE clause and TESTCOURSE should not be there according to the flexigrid search condition.

Any thoughts?

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 28 April 2012 - 11:12 AM

Yeap it is a bug.

I track it as an issue at git-hub ( https://github.com/scoumbourdis/grocery-crud/issues/23 ) and I will try to fix it as for the next vesion (1.2.2) . The good news are that the 1.2.2 is mostly bug fixes. So far for the version 1.2.2 I have fix the following bugs:

#13 - The list search and ordering is not working with the n-n relation columns.

Also small bug fixes:
#20 - Pressing tab and enter after adding a date or a datetime field it clears the date.
#21 - By default the texteditor transform the utf8 to html entities.
#22 - Doesn't recognize that a tinyint 1 or int 1 can just take a numeric value more than 1.


Thanks to mention it.

carlinchisart

carlinchisart
  • profile picture
  • Member

Posted 22 February 2013 - 21:03 PM

Hi,  @web-johnny, i have one problem...

 

i have a version 1.3.3 of grocery crud, but when i use search option the $crud->where rule no work, i see the sql when i mark all field for search the $crud->where rule work, but when i select a specific colum or field to search the $crud->where() rule no work.

 

can you helpme ?


victor

victor
  • profile picture
  • Member

Posted 24 February 2013 - 20:47 PM

carlinchisart, show your code


carlinchisart

carlinchisart
  • profile picture
  • Member

Posted 25 February 2013 - 13:09 PM

Hi @victor,

 

i see in other grocery crud function, but i have the same result, this is the code of my function

 

 $crud = new grocery_CRUD();
        $crud->set_table('anticipos');
        $crud->where('estado', 'transferido');
        $crud->where('id', $this->dx_auth->get_user_id());
        $crud->unset_operations();
        $crud->set_relation('idbeneficiario', 'beneficiarios_anticipos', '{nombre} {apellidos} {cedula}');
        $crud->callback_column('detalle_solicitud', array($this, '_callback_detalle_solicitud'));
        $crud->callback_column('legalizaciones_realizadas', array($this, '_callback_legalizaciones_realizadas'));
        $crud->callback_column('id', array($this, '_callback_quienes_solicita'));
        $crud->callback_column('valor_autorizado', array($this, '_callback_money_format'));
        $crud->columns('idanticipo','fecha_solicitud','numero_tesoreria' ,'id', 'idbeneficiario', 'detalle_solicitud', 'idproyecto','numero_de_orden_de_servicio','valor_autorizado', 'legalizaciones_realizadas');
        $crud->set_relation('idproyecto', 'proyectos', 'nombre_proyecto');
        $crud->display_as('idproyecto','Proyecto');
        $crud->display_as('idanticipo', 'Numero anticipo');
        $crud->display_as('idproyecto','Proyecto');
        $crud->display_as('idbeneficiario', 'Beneficiario');
        $crud->display_as('id', 'Solicitado por');
        $crud->add_action('Registrar legalizacion', base_url() . 'images/autorizar.png', '', 'ui-icon-image', array($this, '_redirecLegalizacionAnticipo'));
        $output = $crud->render();
        $output->ruta_vista = 'example';
        $this->load->view('includes/templeate', $output);

the problem is when i select for search the field 'beneficiario', if i select other field the search work ok.

 

I delete the fields in relation idbeneficiario only put the field nombre in the relation, remove 'apellidos' and 'cedula', so the search work fine!!!.

 

i think the problem is when the relation have more that one field.