Jump to content


Get filter list from the database.

select filter exclude

  • Please log in to reply
12 replies to this topic

#1 dontako

dontako

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationSantiago

Posted 13 November 2012 - 07: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
Posted Image

#2 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 13 November 2012 - 07:32 PM

Hi! Use the "where".

$crud = new grocery_CRUD();
$crud->set_table('usuario');
$crud->where('id !=', 1);
$output = $crud->render();
$this->_example_output($output);

documentation here:
http://www.grocerycr...m/documentation

#3 dontako

dontako

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationSantiago

Posted 13 November 2012 - 08:54 PM

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

#4 JerothKP

JerothKP

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationValencia, Spain

Posted 11 March 2013 - 04: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?



#5 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 19 March 2013 - 02: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.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#6 JerothKP

JerothKP

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationValencia, Spain

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



#7 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 20 March 2013 - 08:31 AM

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

#8 JerothKP

JerothKP

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationValencia, Spain

Posted 20 March 2013 - 09:55 AM

Yes  :)



#9 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 20 March 2013 - 10:22 AM

what theme do you use?

#10 JerothKP

JerothKP

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationValencia, Spain

Posted 20 March 2013 - 10:47 AM

I'm using a custom one based on flexigrid



#11 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

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.

#12 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 25 March 2013 - 01: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!!! ;-)


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#13 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 25 March 2013 - 01:38 PM

l'm going to think about that ;-)





Also tagged with one or more of these keywords: select, filter, exclude

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users