HOW TO create autocomplete fields in CGridView filters?

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6169
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO create autocomplete fields in CGridView filters?

Postby administrator » Feb 4th, '17, 21:06

To create autocomplete fields sin filtering section in CGridView you have to define them in following format:

Search by name:

Code: Select all

'filters'=>array(
    'name' => array('title'=>A::t('app', 'Name'), 'type'=>'textbox', 'operator'=>'like%', 'width'=>'140px', 'maxLength'=>'', 'autocomplete'=>array('enable'=>true, 'ajaxHandler'=>'Ajax/getLocations',
),


Search by id:

Code: Select all

'filters'=>array(
    'id' => array('title'=>A::t('app', 'Name'), 'table'=>CConfig::get('db.prefix').'countries', 'type'=>'textbox', 'operator'=>'like%', 'width'=>'140px', 'maxLength'=>'', 'autocomplete'=>array('enable'=>true, 'ajaxHandler'=>'Ajax/getLocations', 'minLength'=>2, 'returnId'=>true)),
),


Result:
Untitled1.png
Untitled1.png (27.83 KiB) Viewed 2781 times

Return to “ApPHP Directy CMF {developers/users}”