2amigos / yii2-multi-select-widget

Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
https://2amigos.us
Other
45 stars 29 forks source link

MultiSelect as column in yii2 GridView #11

Open Tlopasha opened 7 years ago

Tlopasha commented 7 years ago

is it possible to use MultiSelect widget as column in GridView ?

for example :


GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'layout'=>"{items}",
        'showOnEmpty' => true,
        'columns' => [
                    [
                        'attribute' =>'itemgroup_id',
                        'content' => function($data){ return $data->itemgroup->getTitle(); } ,
                        'filter'=> MultiSelect::widget([
                                        'id'=>"multiXX",
                                       "options" => ['multiple'=>"multiple"], 
                                       'data' => [ 0 => 'super', 2 => 'natural'], 
                                       'value' => [ 0, 2], 
                                       'name' => 'multti',
                                      "clientOptions" => 
                                        [
                                          "includeSelectAllOption" => true,
                                          'numberDisplayed' => 2
                                            ], ])]>`
tonydspaniard commented 7 years ago

It shouldn't be a problem. But you need to set the filter to the widget. Here with the date: http://www.2amigos.us/blog/how-to-add-a-date-range-picker-to-filter-for-dates-on-a-gridview-for-yii2