datagrid icon indicating copy to clipboard operation
datagrid copied to clipboard

inLineEdit - onSubmit function delivers empty values of hidden colums

Open janmottl opened this issue 6 years ago • 5 comments

inLineEdit - onSubmit function delivers empty values of hidden colums. That's very insidious and dangerous because it causes destroying of data in invisible columns.

I have following workaround: ` $this->hiddenColumns = $grid->getSessionData('_grid_hidden_columns');

    $grid->getInlineEdit()->onSubmit[] = function($id, $values) {
        $notHiddenValues = [];
        foreach ($values as $key => $value) {
            // zjistit je column hidden a vynechat ho
            if (empty($this->hiddenColumns) || (!in_array($key, $this->hiddenColumns, true))) {
                $notHiddenValues[$key] = $value;
            }
        }

        if ($this->db->table('cenik')->where('cenik_kod=?', $id)->update($notHiddenValues) !== false) {
            $this->logManager->recordTableUpdate('cenik', $notHiddenValues, $notHiddenValues,
                'cenik_kod', $id);
            $this->flashMessage('Ceníková položka byla uložena', self::MSG_SUCCESS);
        } else {
            $this->flashMessage('Chyba při uložení ceníkové položky', self::MSG_ERROR);
        }

        $this->redrawControl('headerSnippet');
    };

`

janmottl avatar Mar 02 '18 08:03 janmottl

@janmottl Would do you propose?

paveljanda avatar Oct 05 '18 16:10 paveljanda

My proposal is to add a new parameter to onSubmit function. Additional parameter would create no troubles for existing applications. /* $visibleColumnValues - values of visible columns $hiddenColumns - names of hidden columns */ $grid->getInlineEdit()->onSubmit[] = function($id, $visibleColumnValues, $hiddenColumns) { }

janmottl avatar Oct 07 '18 04:10 janmottl

Could you please send a PR into branch v6.x? Thanks a lot. I like your suggestion

paveljanda avatar May 14 '19 20:05 paveljanda

yes. I hope I have done what you have expected.

janmottl avatar May 15 '19 05:05 janmottl

Any progress on this one? We just lost some data because of this...

novacto3 avatar Jul 22 '20 18:07 novacto3