R
R
romany42016-10-22 15:30:31
Yii
romany4, 2016-10-22 15:30:31

Is it possible to export a field from a kartik grid when using input when displaying data?

There is data output through Kartik-grid .
However, some of the columns use the settings, as in the example below

[
        'attribute' => 'email',
        'width' => '150px',
        'value' => function ($model, $key, $index, $widget) {
            return Html::input('text', 'email', $model->email, ['class' => 'kartik-field', 'readonly' => 'readonly']);
        },
        'format' => 'raw',
    ],

Those. when displaying information, input is used (in view of the peculiarities, it is undesirable to refuse to use input).
So - when using the Kartik Export widget, the columns that used input to display information will be empty when viewing a document created based on export.
If you replace input with normal output, the data appears in the export file.
Has anyone had to deal with the solution of a similar problem - the correct display of input fields during export?
Is it possible to add plain text to the input?
'value' => function ($model, $key, $index, $widget) {
            return Html::input('text', 'email', $model->email, ['class' => 'kartik-field', 'readonly' => 'readonly']) . '<span class="hidden">'.$model->email.'</span>';
        },

And to make it invisible for viewing, but shown when exporting?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-10-22
@romany4

This is not a question for gridview, but for KartikExport. You need to create your own class, inherit from KartikExport and override the methods that cut the input. Haven't dug deep there, but I think he's just trimming the tags.
If so, then theoretically everything is simple, you can insert a span with opacity: 0 next to the input; and data inside.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question