Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid: after edit redraw all rows #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

DataGrid: after edit redraw all rows #69

wants to merge 1 commit into from

Conversation

vitkutny
Copy link

After editing the row could not be in result when not ordered by ID w.
If there are data in grid sorted by name and i change the name using inline edit this row can be now on different page and grid needs to redraw all rows.

After editing the row could not be in result when not ordered by ID w.
If there are data in grid sorted by name and i change the name using inline edit this row can be now on different page and grid needs to redraw all rows.
@hrach
Copy link
Member

hrach commented Mar 14, 2017

This is probably not a good idea. When you change a field which is the grid sorted by, you probably don't want to redraw all rows and lost the row.

But you probably want this - so I think you can manually invalidate all rows, can't you?

@vitkutny
Copy link
Author

vitkutny commented Mar 14, 2017

This is probably not a good idea. When you change a field which is the grid sorted by, you probably don't want to redraw all rows and lost the row.

This will be best behaviour. But does not work right now. After edit it throws exception that row is not found.

I tried it and ended with following code (from v2.1.3). It loads data before editing row and disables redirect so data in grid does not change. But there are some problems, it preserves post request and when refreshing page it submits edit form again and it rely on all rows in data are objects and editFormCallback change data of edited object.

It would be better if inline edit supported ajax. And this behaviour of preserving edited row in grid will work only in ajax requests.

	public function processForm(UI\Form $form)
	{
		$allowRedirect = TRUE;
		if (isset($form['edit'])) {
			if ($form['edit']['cancel']->isSubmittedBy() || ($form['edit']['save']->isSubmittedBy() && $form['edit']->isValid())) {
				$editRowKey = $form['edit'][$this->rowPrimaryKey]->getValue();
				$this->invalidateRow($editRowKey);
				try {
					$this->getData($editRowKey);
				} catch (\Exception $e) {
					if ($e->getMessage() === 'Row not found') {
						$this->invalidateControl('rows');
					} else {
						throw $e;
					}
				}
				$allowRedirect = FALSE;
			}
			if ($form['edit']['save']->isSubmittedBy()) {
				if ($form['edit']->isValid()) {
					Callback::invokeArgs($this->editFormCallback, array(
						$form['edit']
					));
				} else {
					$this->editRowKey = $form['edit'][$this->rowPrimaryKey]->getValue();
					$allowRedirect = FALSE;
				}
			}
			if ($this->editRowKey !== NULL) {
				$this->invalidateRow($this->editRowKey);
			}
		}
}

@hrach
Copy link
Member

hrach commented Mar 14, 2017

This will be best behaviour. But does not work right now. After edit it throws exception that row is not found.

so that's the bug.

@hrach hrach added the T:Bug label Mar 14, 2017
@hrach hrach added this to the 3.0 milestone Mar 14, 2017
@hrach
Copy link
Member

hrach commented May 10, 2017

Sorry, I don't understand this issue fully.

  • do you report issue in ajax or without ajax
  • what is exactly the exception, could you porivde tracy bluescreen?

@hrach
Copy link
Member

hrach commented Jul 31, 2017

ping @vitkutny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants