【问题标题】:Yii2 kartik-v gridview: TypeError: jQuery(...).editable is not a functionYii2 kartik-v gridview: TypeError: jQuery(...).editable is not a function
【发布时间】:2015-03-31 07:04:39
【问题描述】:

当第一次将第一个新数据插入 gridview 时(此时 gridview 中没有来自数据库的数据),所有可编辑列都显示为故障按钮而不是工作链接。刷新页面后,Gridview 中的 Editable 列按预期显示为链接并且正常工作。

为什么只有第一次出现这个问题?

这是将第一个新数据插入 Gridview 后显示的错误。

TypeError: jQuery(...).editable 不是函数

这是我的专栏:

             [
                'class' => 'kartik\grid\EditableColumn',
                'attribute' => 'short_desc',
                'refreshGrid' => true,
                'editableOptions' => function ($model, $key, $index) {
                    return [
                        'header'=>'short_desc',
                        'size'=>'md',

                    ];
                }
            ]

谢谢。

【问题讨论】:

    标签: jquery gridview yii2


    【解决方案1】:

    即使在 pjax 重新加载后,当只有一个数据(第一个数据)时,我也已经解决了我的代码以刷新页面。

    在我的 addNewData() 的 jquery 函数中,我在新数据添加成功后 pjax reload 后添加了以下代码:

    <?php                       
         $models = $dataProvider->getModels(); // get dataProvider to check if there is any data
    
         // refresh whole page for the first newly added data when there is only one data as in Editable Column not initiated when there is no data
         if( count($models) < 1 || $models == null || !isset($models) )                         
         {
     ?>
             window.location.reload();
     <?php                              
         }                      
     ?>
    

    这对我现在有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 2014-09-09
      相关资源
      最近更新 更多