⚠ 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 custom action with if condition



Racing Chocobo
  • profile picture
  • Member

Posted 03 August 2013 - 05:49 AM

Hi, I have one question about grocery crud API function "add_action"

 

My question is, is there any method that can dynamically put "add_action" within the datatables?

 

I mean I don't want to put the action in every column of the table, but only some of them

 

For example, I only want to put add_action if the column has odd number of index.

 

Maybe something like:

if($crud->column('id') % 2 == 0){
     $crud->add_action('More', '', '','ui-icon-plus', array($this, 'some_function'));
}

Is there any method that can implement this one?

 

Thank you very much!


davidoster
  • profile picture
  • Member

Posted 03 August 2013 - 08:43 AM

I am afraid you cannot do it like this.

add_action generates the required action and this is global for all of the rows of the table.

The only way to do this is by having a fake column at the end, which will show just before the actions and by using the callback_column to display (or not) the required action.


Racing Chocobo
  • profile picture
  • Member

Posted 03 August 2013 - 13:13 PM

Ok I'll do it by another method, maybe by using Jquery to remove the action button relatively.

 

Thank you!