【问题标题】:data-pk attribute not showing in the x-editable CGridviewx-editable CGridview 中未显示 data-pk 属性
【发布时间】:2014-04-17 09:32:23
【问题描述】:

我正在使用 x-editable 在 CGridview 中使用内联编辑。 http://x-editable.demopage.ru/index.php 我使用 postgresql 作为数据库。问题是我在 postgres 中使用函数来编写查询,并且我从 yii 调用这些函数。我使用的数据提供者是 CSqlDataprovider。因此,在使用内联编辑时,data-pk 属性不会显示在网格视图中。所以更新不起作用。请帮忙。

【问题讨论】:

    标签: php postgresql yii yii-extensions x-editable


    【解决方案1】:

    尝试将dataProvider的keyField设置为'id'。

    dataProvider->keyField ='id';
    

    【讨论】:

      【解决方案2】:

      您可以指定 PK 在您的 X-editable 列中有一个参数:

      $this->widget('editable.EditableField', array(
          'type'         => 'select',
          'model'        => $data,
          'attribute'    => 'user_status',
          'url'          => $this->createUrl('site/updateUser'),
          'pk'           => 'id',
          ));
      
      ?>
      

      如果您需要更多详细信息,请向我们提供有关您的 CgridView 列和需要保存的数据的更多信息。

      Source

      【讨论】:

      • 它不工作。除了“pk”之外的所有其他 pramateres 都在工作。我试过 'pk'=> '$data["id"]',
      • pk 必须是 pk 属性的名称。请发布更多代码
      猜你喜欢
      • 1970-01-01
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多