⚠ 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

Get filter list from the database.



dontako

dontako
  • profile picture
  • Member

Posted 13 November 2012 - 19:03 PM

I have a users table with 10 records, if I want to get them just do something like this:

 $crud = new grocery_CRUD();
$crud->set_table('usuario');
$output = $crud->render();
$this->_example_output($output);


With this I get 10 results in mygrid, now my question .... If I want to get all users except the user with ID 1, as I should?

I need to change the model? (grocery_crud_model.php)

regards :P

victor

victor
  • profile picture
  • Member

Posted 13 November 2012 - 19:32 PM

Hi! Use the "where".

$crud = new grocery_CRUD();
$crud->set_table('usuario');
[color=#ff0000]$crud->where('id !=', 1);[/color]
$output = $crud->render();
$this->_example_output($output);

documentation here:
http://www.grocerycrud.com/documentation

dontako

dontako
  • profile picture
  • Member

Posted 13 November 2012 - 20:54 PM

wow, did not know you could put that in the controller. Thank you! :D

JerothKP

JerothKP
  • profile picture
  • Member

Posted 11 March 2013 - 16:56 PM

Hi, how could this be done dynamically? I mean, if I want to use a select to filter my table dynamically (using ajax), how could I do it?


davidoster

davidoster
  • profile picture
  • Member

Posted 19 March 2013 - 14:11 PM

It's not a straight forward answer actually!

Both themes currently have a filtering (aka where capability). See if you can play with it.


JerothKP

JerothKP
  • profile picture
  • Member

Posted 20 March 2013 - 08:08 AM

I've done it storing data in a session variable and reloading the page, but I would like to do it without reloading


victor

victor
  • profile picture
  • Member

Posted 20 March 2013 - 08:31 AM

do you want to use a dropdown to filter your table?

JerothKP

JerothKP
  • profile picture
  • Member

Posted 20 March 2013 - 09:55 AM

Yes  :)


victor

victor
  • profile picture
  • Member

Posted 20 March 2013 - 10:22 AM

what theme do you use?

JerothKP

JerothKP
  • profile picture
  • Member

Posted 20 March 2013 - 10:47 AM

I'm using a custom one based on flexigrid


victor

victor
  • profile picture
  • Member

Posted 20 March 2013 - 11:43 AM

my thinking:
you need to do two requests via Ajax.
you will use the first request to set session data.
Second request is to get list of rows and replace old table on new. Take a look at request which script send to get the list.
Note: There are state system www.grocerycrud.com/documentation/options_functions/getState
you should send the state in the second request.
Sorry for my newbies English.

davidoster

davidoster
  • profile picture
  • Member

Posted 25 March 2013 - 13:34 PM

my thinking:
you need to do two requests via Ajax.
you will use the first request to set session data.
Second request is to get list of rows and replace old table on new. Take a look at request which script send to get the list.
Note: There are state system www.grocerycrud.com/documentation/options_functions/getState
you should send the state in the second request.
Sorry for my newbies English.

 

 

Victor this sounds like a good addon library for GC!!! ;-)


victor

victor
  • profile picture
  • Member

Posted 25 March 2013 - 13:38 PM

l'm going to think about that ;-)