php - How to create a custom ActionColumn in the gridView of yii2? -


I have a gridview and I have managed to keep the data needed, but what I need to do next

  & lt ;? = GridView :: Widgets (['dataProvider' => $ data provider, 'filter modell' = & gt; $ search mode, '' column '= & gt; [[' class '= & gt;' yii \ grid \ SerialColumn '],' Name ',' semi_name ',' is_fosbook ',' is_tivety ', [' class' => 'yii \ grid \ actionColumn'],],]); ? & Gt;  

name | Cm_name | Platform

Account1 | Jack | BTN1BTN2

Where BTN1 and BTN2 refer to Facebook and Twitter.

Sorry for the dissected table.

You do not need to create your column class. You can create simple raw-columns and can show anything you want:

  ['attribute' = & gt; 'Some_title', 'format' = & gt; 'Raw', 'value' = & gt; Function ($ Models) {Return '& lt; Div & gt; ' $ Model- & gt; Id. 'And other HTML-code & lt; / Div & gt; '; },  

this function

  function ($ model) {return '& lt; Div & gt; ' $ Model- & gt; Id. And other HTML-code & lt; / Div & gt; '; }  

Name callback function. The main method is:

  Public function evaluation expression ($ _ expression _, $ _ data_ = array ()) {if (is_string ($ _ expression)) {extract ($ _ data_); Return Aval ('return'. $ _ Expression. ';'); } And {$ _data _ [] = $ this; Return call_user_func_array ($ _ expression, $ _data_); }}  

The expression in our case is not a string, it is a function, so it runs the PHP method and pass it in its model.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -