⚠ 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

looking for example of "Add a custom action control"



richb201

richb201
  • profile picture
  • Member

Posted 03 January 2018 - 18:15 PM

I see the example in the docs but I don't actually get it. 

 

These are the add actions for the demo. 

 

$crud->add_action('More', '', 'demo/action_more','ui-icon-plus');
$crud->add_action('Photos', '', '','ui-icon-image',array($this,'just_a_test'));
$crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'demo/action_smiley');

 

When I click on the +More button in the demo I get:

Just a test function for more button and id: 2
Go back to example

 

Where is the function that prints that? I don't see a function name or  a link-url.

 

void add_action( string $label, string $image_url , string $link_url , string $css_class , mixed $url_callback)

 

On the second add action,  Photos, when I press I get:

 

Just a test function for photos button and country: UK
Go back to example

 

But where is the code that is generating that? 

 

 


fapth

fapth
  • profile picture
  • Member

Posted 05 January 2018 - 13:57 PM

void add_action( string $label, string $image_url , string $link_url , string $css_class , mixed $url_callback)

 

 

the code its ganerating is a new side. on click on this button its load a new side in Codeigniter! So : $link_url = "Controller/Method"  is the same like anchor('controler/method')

 

I hope i could help you


richb201

richb201
  • profile picture
  • Member

Posted 05 January 2018 - 22:02 PM

fapth, thanks for your comment. What I truly would like to see is the code behind the example on this page:

 

https://www.grocerycrud.com/documentation/options_functions/add_action

 

I see it works but just want to see the code so I can emulate it.  When I use add_action, the url_callback is running for every row in my list. If I understand  what you are saying is that using the link_url instead of the url_callback might work to only run when i click on it?


fapth

fapth
  • profile picture
  • Member

Posted 09 January 2018 - 10:52 AM

yes this is how i used it:

$crud->add_action('open', '', 'controller/redir','glyphicon glyphicon-eye-open');

its calling my controller/redir with id like this /controller/redir/3

 

im not getting what you want to do.


richb201

richb201
  • profile picture
  • Member

Posted 09 January 2018 - 20:49 PM

And you go to your controller/redir function. Right?  What do you do to get the crud to redisplay the list in redir()?


fapth

fapth
  • profile picture
  • Member

Posted 10 January 2018 - 10:16 AM

your controller function can do what u want and put u back to list by redirect('crud_controller/').

 

its like

 

class User extends CI_CONTROLLER

 

function __construct(){

 

}

public function redir($id){

//do something here

redirect('crud_controller');

}

}