using dropdownlist in CGridView

Discuss everything related to ApPHP MVC Framework. All versions. Any questions related to the Framework developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

paragate
Master
Master
Posts: 151
Joined: Nov 13th, '14, 13:04
Location: Denmark, Odense

using dropdownlist in CGridView

Postby paragate » Aug 10th, '17, 07:00

Hi,
Tried to use dropdownlist in Filters but list is empty

Code: Select all

"Clients" =>array(
                    "type"=>"enum",
                    "view_type"=>"dropdownlist",
                    "table"=>CConfig::get('db.prefix').'accounts',
                    "field"=>"id",
                    "field_view"=>"id",
                    "source"=>"self"),


Do i have to define the variable 'dropdownlist' myself and then it filters with table? Or should the values from table come up in the dropdownlist?
Regards

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: using dropdownlist in CGridView

Postby ne_moj » Aug 11th, '17, 08:32

Hi

You must prepare an array for the drop-down list:

Code: Select all

$accounts = array('0'=>'Henrik', '1'=>'Sergey', '2'=>'Sam', ...);
....
'filters' => array(
   ....
   'сlients' => array(
      'title'=>'Clients',
      'type'=>'enum',
      'table'=>CConfig::get('db.prefix').'accounts',
      'operator'=>'=',
      'default'=>'',
      'width'=>'',
      'source'=>$accounts,
      'emptyOption'=>true,
      'emptyValue'=>'-- select --',
      'htmlOptions'=>array(
         'class'=>'chosen-select-filter'
      )
   ),
   ....
),

paragate
Master
Master
Posts: 151
Joined: Nov 13th, '14, 13:04
Location: Denmark, Odense

Re: using dropdownlist in CGridView

Postby paragate » Aug 11th, '17, 09:26

Thanks,
Working with

Code: Select all

'operator'=>'%like%',
i also removed 'table'.

question:
What is the function of "table"=> "..."?

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: using dropdownlist in CGridView

Postby ne_moj » Aug 14th, '17, 06:36

Hello Henrik,

Question:
What is the function of "table" => "..."?


This is needed when several tables are used in the model to precisely specify which table to sort.

Regards


Return to “ApPHP MVC Framework {developers/users}”