⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠


Calculate a column with the fields of other columns through a callback_column

callback column calculation

  • Please log in to reply
2 replies to this topic

#1 mbanolas2

mbanolas2

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 10 January 2017 - 09:35 PM

Hi,

I am using a callback_column using the information from other column using a callback_column function.

This is just an example:

 

$this->grocery_crud->callback_column('total',array($this,'_callback_column_total'));

 

public function _callback_column_total($value, $row){
        $a=$row->a;
        $b=$row->b;
        $total=$a+$b;
        return $total;
    }
 
It works fine, but in the case I add some custom styles, por example in column a with another callback:
 
public function _callback_column_a($value, $row){
        return "<span style='text-align:right;padding-right:30px;width:100%;display:block;'>".$value."</span>";
    }

 

then, the calculation for column total does not work anymore.

I have two questions:

1. Why it happens? It is because the value of a is  "<span style='text-align:right;padding-right:30px;width:100%;display:block;'>".$value."</span>" and not the value of a?

2. Is it possible to put the custom style with other method? I tried using javascript but it does not work when I do a search in a column.

Thanks in advance for your support.

Miguel

 

 

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 18 January 2017 - 02:34 AM

Hi mbanolas2

 

Yes - this is probably a cause due to the column callback on column a... What u can do is use php's strip_tags to get rid of the tags decorated around the value on column a...

Post that .. u can surely go ahead and use it as raw value and get your output as desired.

 

Happy GCing :)



#3 rkrajnik

rkrajnik

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 02 November 2020 - 10:37 PM

Is it possbile to get real help/insight on issues like this?







Also tagged with one or more of these keywords: callback, column calculation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users