📜 ⬆️ ⬇️

how to get data from EditorGridPanel

On one of the projects, it was decided to use ExtJS to display and edit tabular data. Ie, we needed a grid.
Connecting and filling it with data does not cause any special problems. The Internet is full of instructions with examples.
The problems started when trying to get data in a php script. When sabmite data was transmitted only from the last modified cells in the column. If 2 or more cells were changed in the column, the last one came because they had the same names.
So the question was how to assign individual IDs to the cells?
The correct answer is no way.

Hehe, in search of this answer, I killed 4 hours.
The fact is that the grid basically does not store data in the form in which our html-form can understand and transmit it. Therefore, by the way, it makes no sense to insert our grid into it. Those values ​​that come to the script through POST are just a legacy of input-s in which the content was edited.
In order to obtain data, we will have to attend to their collection and cracking in the form, for example, in the hidden input.
This is done simply.
First of all, in the constructor of the grid we will add the event “afteredit”, which will call our function every time the contents of the cell are changed.

grid.on('afteredit', dataCollector);

Here the grid is our Ext.grid.EditorGridPanel object, and dataCollector is the name of the function that will be called.
And here is its code:

function dataCollector(oGridEvent)
{
col = oGridEvent.field; // ,
CellValue = oGridEvent.value; //
row = oGridEvent.row + 1; // ,

// ,

...

}

')
Somehow like this. At first I posted to myself , but then I thought that this could be useful for habra people. There is little information in Russian about this “great and mighty” framework.

UPD. Wrote an article with examples of working with Ext.grid.EditorGridPanel . Saving data is done in a not so barbaric way :)

Source: https://habr.com/ru/post/44001/


All Articles