⚠ 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

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



mbanolas2

mbanolas2
  • profile picture
  • Member

Posted 10 January 2017 - 21: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

 

 

 


Amit Shah

Amit Shah
  • profile picture
  • Member

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 :)


rkrajnik

rkrajnik
  • profile picture
  • Member

Posted 02 November 2020 - 22:37 PM

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