开发者

Zend Dojo Filtering Select only returning one value

Hi can anyone please tell me why the following code is only returning the single value 2,bath

The autocomplete action from my controller

  public function groomappointserviceAction()
   {

    $this->_helper->layout->disableLayout();
    $this->getHelper('viewRenderer')->setNoRender(true);

    // get a list of all grooming services IDs and related procedures
   $gqry= Doctrine_Query::create()
   ->select('g.groomServicesID AS iden , p.groomprocedure AS name')
   ->from('PetManager_Model_Groomservices g')
   ->leftJoin('g.PetManager_Model_Groo开发者_JAVA百科mprocedures p');
   $result = $gqry->fetchArray();

   //generate and return JSON string 
    $data = new Zend_Dojo_Data('iden',$result);
    echo $data->toJson();
  }

The filteringselect of my form

  // Create a autocomplete select input for the grooming
    $gservice = new Zend_Dojo_Form_Element_FilteringSelect('gapmtService');
    $gservice->setLabel('Proceedure');
            $gservice->setOptions(array(
            'autocomplete' => true,
            'storeID'   => 'groomappointserviceStore',
            'storeType' => 'dojo.data.ItemFileReadStore',
            'storeParams' => array('url' => "/groomappointments/appointment/groomappointservice"),
      'dijitParams' => array('searchAttr' => 'name')))
        ->setRequired(true)
        ->addValidator('NotEmpty', true)
        ->addFilter('HTMLEntities')            
        ->addFilter('StringToLower')        
        ->addFilter('StringTrim');

When the same (I Believe) query in MySQL returns

mysql> select g.groomservicesid AS iden , p.groomprocedure as name
     -> from groomservices AS g LEFT JOIN groomProcedures AS p
     -> on g.groomProcedure = p.groomProceduresID;
 +------+--------------------------+
 | iden | name                     |
 +------+--------------------------+
 |    2 | Bath                     |
 |    7 | Bath                     |
 |    8 | Bath                     |
 |    9 | Bath                     |
 |    1 | Nail Clip                |
 |    4 | Nail Clip                |
 |    5 | Nail Clip                |
 |    6 | Nail Clip                |
 |   19 | Shed Less                |
 |   20 | Shed Less                |
 |   21 | Shed Less                |
 |   22 | Shed Less                |
 |   13 | Dematting/Hand Stripping |
 |   14 | Dematting/Hand Stripping |
 |   15 | Dematting/Hand Stripping |
 |   16 | Dematting/Hand Stripping |
 |   17 | Dematting/Hand Stripping |
 |   18 | Dematting/Hand Stripping |
 |    3 | Bath Brush               |
 |   10 | Bath Brush               |
 |   11 | Bath Brush               |
 |   12 | Bath Brush               |
 +------+--------------------------+
 22 rows in set (0.00 sec)


Ok I've actually sorted this by changing the code to that below. Not sure why it is now working as I tried this earlier but it didn't work.

My autocomplete action

public function groomappointserviceAction()
{

    $this->_helper->layout->disableLayout();
    $this->getHelper('viewRenderer')->setNoRender(true);

   // get a list of all grooming services IDs and related procedures
   $gqry= Doctrine_Query::create()
       ->select('g.groomServicesID, p.groomprocedure AS name')
       ->from('PetManager_Model_Groomservices g')
      ->leftJoin('g.PetManager_Model_Groomprocedures');
   $result = $gqry->fetchArray();

  //generate and return JSON string 
  $data = new Zend_Dojo_Data('groomServicesID',$result);
  echo $data->toJson();
}

The FilteringSelect on my form

  // Create a autocomplete select input for the grooming
    $gservice = new Zend_Dojo_Form_Element_FilteringSelect('gapmtService');
    $gservice->setLabel('Proceedure');
    $gservice->setOptions(array(
      'autocomplete' => true,
      'storeID'   => 'groomappointserviceStore',
      'storeType' => 'dojo.data.ItemFileReadStore',
      'storeParams' => array('url' => "/groomappointments/appointment/groomappointservice"),
      'dijitParams' => array('searchAttr' => 'name')))
        ->setRequired(true)
        ->addValidator('NotEmpty', true)
        ->addFilter('HTMLEntities')            
        ->addFilter('StringToLower')        
        ->addFilter('StringTrim');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜