Yii Framework Forum: Tbtypeahead - Zapytanie Z Bazy - Yii Framework Forum

Jump to content

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

Tbtypeahead - Zapytanie Z Bazy Rate Topic: -----

#1 User is offline   tzoll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 28-February 13

Posted 18 April 2013 - 06:00 AM

Cześć. Czy ktoś mógłby mi podpowiedzieć jak w TbTypeAhead pobierać dane z bazy a nie ze zwykłej statycznej tablicy? Próbowałem coś takiego ale nie działa.
<?php $this->widget('bootstrap.widgets.TbTypeahead', array(
    'name'=>'typeahead',    
    'options'=>array(
        'source'=>$this->createUrl('request/suggest'),
        'items'=>4,
        'matcher'=>"js:function(item) {
            return ~item.toLowerCase().indexOf(this.query.toLowerCase());
        }",
    ),
)); ?>


Dzięki za pomoc
Pozdrawiam
Tomek
0

#2 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 18 April 2013 - 06:10 AM

$zm= Model::model()->findAll();
$var = CHtml::listData($zm, 'some', 'id');
      $this->widget('bootstrap.widgets.TbTypeahead', array(
            'name'=>'typeahead',    
            'options'=>array(
                'source'=>$var ,
                'items'=>4,
                'matcher'=>"js:function(item) {
                    return ~item.toLowerCase().indexOf(this.query.toLowerCase());
                }",
            ),
        ));

0

#3 User is offline   tzoll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 28-February 13

Posted 18 April 2013 - 11:45 AM

Niestety nie działa...
0

#4 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 19 April 2013 - 01:07 AM

Pokaz kod i napisz co nie dziala. Pobranie z bazy czy listData?
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