⚠ 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

Add_action not working



kstadler
  • profile picture
  • Member

Posted 17 August 2012 - 09:08 AM

Hello,

I'm trying to add a custom action using the following code:

$crud->add_action('Vorschau', '', 'banner/preview');

However, for some reason the added Action does not show up.
What did I do wrong?

mikelamar
  • profile picture
  • Member

Posted 17 August 2012 - 09:58 AM

If you are using the default flexigrid theme you have to use an image as the second parameter to make it work. For example:


$crud->add_action('Vorschau', '/images/preview.png', 'banner/preview');


The examples at the website without a second parameter I think is only for datatables theme but not sure about it.

kstadler
  • profile picture
  • Member

Posted 17 August 2012 - 12:01 PM

Thanks, that solved the problem!

kstadler
  • profile picture
  • Member

Posted 17 August 2012 - 12:15 PM

The next problem wasn't far away...
The action displays with a image now.
But for some reason the target link is not as expected.
It should link to banner/preview/id. Instead it links to id.
I'm using the following code:

$crud->add_action('Vorschau', site_url('/assets/images/preview.png', 'banner/preview'));

What did I do wrong this time around?

mikelamar
  • profile picture
  • Member

Posted 18 August 2012 - 08:55 AM

Your syntax is wrong you forgot to close the parenthesis , so instead of:


$crud->add_action('Vorschau', site_url('/assets/images/preview.png', 'banner/preview'));


you have to change it to:


$crud->add_action('Vorschau', site_url('/assets/images/preview.png'), 'banner/preview');


[b]Suggestion[/b]: is better for images/css/js to have the base_url instead of site_url. So for example in your case the correct one is:


$crud->add_action('Vorschau', base_url('/assets/images/preview.png'), 'banner/preview');

kstadler
  • profile picture
  • Member

Posted 20 August 2012 - 11:31 AM

So it was just a typo... thanks for pointing me towards it!
Also thanks for the base_url tip.

mikelamar
  • profile picture
  • Member

Posted 20 August 2012 - 18:16 PM

Glad to help :D

webdev23
  • profile picture
  • Member

Posted 29 October 2013 - 19:48 PM

If you are using the default flexigrid theme you have to use an image as the second parameter to make it work. For example:
 

$crud->add_action('Vorschau', '/images/preview.png', 'banner/preview');
The examples at the website without a second parameter I think is only for datatables theme but not sure about it.

 

Tried the above. It does not work. Here's what flexigrid creates for delete button:

<a href='http://localhost/codeigniter/administer/people/delete/02' title='Delete Student' class="delete-row" ><span class='delete-icon'></span></a>

 

Note the SPAN tag above where the flexigrid class is called where the image is called as a background image (what a convoluted way to do this). I see no way to replicate that using add_action. Has anyone successfully does this recently?

 

Thanks.


Amit Shah
  • profile picture
  • Member

Posted 30 October 2013 - 22:33 PM

welll.. u can do it - in the assets/grocery_crud/themes/flexigrid/views/list.php

there is the code to add extra buttons in for the action. You can customize it - i did it for my own :)

 

Else other way around - add a column and make a column callback and create a button of your own choice / taste :)

 

Happy GCIng