0

更新的数据未发布。我正在使用 kartik 高级网格和 kartik 可编辑。

editableAjaxError 不返回任何错误。实际列更新,但似乎没有提交表单数据(可编辑的弹出数据)

更新:添加了 indexAction 和两个网格。主网格和 exandrow 网格模板。

行动指数

public function actionIndex()
    {

        if (Yii::$app->request->isAjax && Yii::$app->request->post('hasEditable')){
            // return empty json object for now
            echo Json::encode(['output' => '', 'message' => Yii::$app->request->post('hasEditable')]);
            return;
        }

        $searchModel = new \common\models\CustomerMasterSearch();
        $queryParams = array_merge(array(),Yii::$app->request->getQueryParams());
        if(isset(Yii::$app->request->queryParams['CustomerMasterSearch']))           
        {

            // some code here

        }  
        $dataProvider = $searchModel->search($queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

意见/index.php

echo GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'pjax' => true,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
            [
                'class' => 'kartik\grid\ExpandRowColumn',
                'value' => function ($model, $key, $index, $column){
                    return GridView::ROW_COLLAPSED;
                },
                'detail' => function ($model, $key, $index, $column){

                    $searchModel = new BrandBudgetSearch();
                    $searchModel->customerid = $model->customerid;

                    $queryParams = array_merge(array(),Yii::$app->request->getQueryParams());
                    $dataProvider = $searchModel->search($queryParams);

                    return Yii::$app->controller->renderPartial('_brandbudget', [
                        'dataProvider' => $dataProvider,
                    ]);
                }
            ],

意见/_brandbudget.php

echo GridView::widget([
            'dataProvider' => $dataProvider,
            'pjax'=>true,
            'columns' => [
                [
                    'attribute' => 'brand_name',
                    'value' => function($model,$key,$idx,$col){
                            return $model['brand_name'];
                        },
                ],
                [
                    'class'=>'kartik\grid\EditableColumn',
                    'value' => function($model,$row){
                            //return $model->brand_name;
                            return $model->getMonthBudget(new DateTime('2017-01'), [11311])['budget_net']; // TODO - Testingv
                        },
                    'editableOptions' => [
                        'name' => 'it requires this without attribute',
                        'header'=>'Jan',
                        'inputType'=>\kartik\editable\Editable::INPUT_SPIN,
                        'options'=>['pluginOptions'=>['min'=>0, 'max'=>5000]],
                        'pluginEvents' => [
                            "editableSuccess"=>"function(event, val, form, data) { console.log(data); }",
                        ]
                    ]
                ],
                [
                    'attribute' => 'Feb',
                    'value' => function($model,$key,$idx,$col){
                            //return $model->brand_name;
                            return $model->getMonthBudget(new DateTime('2017-02'), [11311])['budget_net']; // TODO - Testing
                        },
                ],
                [
                    'attribute' => 'Mar',
                    'value' => function($model,$key,$idx,$col){
                            //return $model->brand_name;
                            return $model->getMonthBudget(new DateTime('2017-03'), [11311])['budget_net']; // TODO - Testing
                        },
                ],
4

0 回答 0