Z
Z
Zittz2017-01-30 17:42:27
Yii
Zittz, 2017-01-30 17:42:27

Is there a way to implement adding rows to a Yii2 GridView from the first row of a table?

The task is to add records to the database not from a separate view, not from a form on the page, but directly from the first line of the GridView.
So that the first row in the GridView does not display data, but has input fields for adding a new record.
Approximately as in the figure
insert-record-gridview.png
, only not the last line, but the first.
So far, only the thought comes to mind after loading the page using js append to add a line with input fields to the beginning of the table, but it is very similar to a crutch.
At the moment, I stopped at using kartik\grid\GridView, but he doesn’t know how to do this either.
Are there more "correct" ways? plugin? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-01-30
@webinar

I haven’t seen it, but in fact you just need to add a form to the table using js. It seems to me that it is more convenient to display it in a modal rather than fooling around with adding a line. And if my memory serves me right, then kartik\grid\GridView has this implemented, just through a modal.
Also take a look here: demos.krajee.com/grid#editable-column-action

Z
Zitttz, 2017-03-02
@Zitttz

I'll answer it myself... I managed to implement this if I disable the filters built into the table...
According to standard html, you can't put a form into a table, you can vice versa... ie. a table inside the form, then in afterHeader we add between the necessary form fields, and everything works ... except for the search, because the search, in fact, also works through the form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question