post by markab on Nov 19, 2021

Is it good practice to do this?

	$crud->callbackAfterInsert(function ($stateParameters) {

		$redirectResponse = new \GroceryCrud\Core\Redirect\RedirectResponse();
		return $redirectResponse->setUrl(base_url().'/SanController/san_records#/edit/' . $stateParameters->insertId);

	});

post by markab on Nov 19, 2021

I think the only thing I note that it does not refresh the datagrid in the background when you do this.

So question is, it there a way to force a refresh of the datagrid in the backgound behind the modal?

post by johnny on Nov 21, 2021

Hello @markab ,

I guess you are looking for the JavaScript trigger?

document.querySelector(".gc-container .fa-refresh").click();

Regards
Johnny

post by markab on Nov 21, 2021

So in my view i added…

	<script>
			
			function refreshDoc() {
			
				document.querySelector(".gc-container .fa-refresh").click();
			}
			
				
	</script>

If I call it from <button onclick="refreshDoc()">Try it</button>

It works fine.

However if I add an event…

window.addEventListener("load", function(){refreshDoc()});

I get the following console error…

san_records:30 Uncaught TypeError: Cannot read properties of null (reading ‘click’)

post by markab on Nov 21, 2021

moved the script element and now no error but when the page redirect runs it still does not refresh the data grid behind.

post by markab on Nov 26, 2021

Still not been able to implement this.

What I essentially want to do is change the close modal on save behaviour.

In the Add form when close modal on save is checked then the modal closes.

In the Add form when close modal on save is not checked then the modal stays open and after save of the insert form then renders the modal as the edit form, so you can make an insert and incremental edits without closing.

In the Edit form when close modal on save is checked then the modal closes.

In the Edit form when close modal on save is not checked then the modal stays open and refreshes the edit form. Now I think this is what it is supposed to do but it only refreshes the datagrid in the background. If you had a callbackBeforeUpdate which modifies a field before update and the modal is set to stay open it does not refresh the edit form with that change.

2 months later

post by daveoreardon on Jan 19, 2022

I’d like to do the same thing. Did this work for you? When I used your code, the redirect results in the datagrid being displayed, not the edit modal (pop-up) for the one item.

post by markab on Jan 19, 2022

No, I think really it needs a change in the software to allow this customisation.

1 / 8
Nov 2021