Yii Framework Forum: $Form->Select2Row Ajax Call Delay - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

$Form->Select2Row Ajax Call Delay Rate Topic: -----

#1 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 05 March 2013 - 04:54 PM

select2row is successfully fetching data from ajax call but I want to set up minlength and delay options, but they are not working.\

Any idea from any one please?
below is my code which is working with ajax call

in _form:
<?php echo $form->select2Row($model, 'city', array(
//'hint'=>'Select your city',
// 'data'=>GxHtml::listData(City::model()->findAll(),'city_id', 'city_name'),
'asDropDownList' => false,
'options' => array(
'delay'=>300,
'minLength'=>3,
'width' => '40%',
'closeOnSelect' => false,
'placeholder' => 'Select City',
'allowClear' => false,
'ajax' => array(
'url' => CController::createUrl('agent/ajaxgetcity'),
'dataType' => 'json',
'data' => 'js:function(term,page) { return {q: term, page_limit: 10, page: page}; }',
'results' => 'js:function(data,page) { return {results: data}; }',
),
)));
?>


In controller:

public function actionAjaxGetCity() {
if (isset($_GET['q'])) {
$cts = City::model()->findAll(array('order'=>'city_name', 'condition'=>'city_name LIKE :city_name', 'params'=>array(':city_name'=>$_GET['q'].'%')));
$data = array();
foreach ($cts as $value) {
$data[] = array(
'id' => $value->city_id,
'text' => $value->city_name,
);
}
echo CJSON::encode($data);
}
Yii::app()->end();
}
0

#2 User is offline   ramasurf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 06-February 12

Posted 31 March 2013 - 04:12 AM

hi
did you resolve this problem?
I have the same problem with select2row
0

#3 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 31 March 2013 - 05:41 AM

No
0

#4 User is offline   canreo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-July 09

Posted 19 April 2013 - 07:12 PM

Try this instead:

'minimumInputLength'=>3,
0

#5 User is offline   Artificial 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 11-December 10
  • Location:Sydney, Australia

Posted 19 April 2013 - 08:41 PM

The above should work. If you're stuck, try reading through the documentation.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users