Zend Dojo过滤选择仅返回一个值

时间:2011-05-14 16:01:21

标签: zend-framework dojo

您好,有人可以告诉我为什么以下代码只返回单值2,浴缸

我的控制器的自动完成操作

  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_Groomprocedures p');
   $result = $gqry->fetchArray();

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

我的表单的过滤选择

  // 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');

当MySQL中的相同(I Believe)查询返回时

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)

1 个答案:

答案 0 :(得分:0)

好的,我实际上通过将代码更改为以下内容对此进行了排序。不知道为什么它现在正在工作,因为我之前尝试过,但它没有用。

我的自动填充动作

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();
}

我表单上的FilteringSelect

  // 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');