Modification of 'remember_state_upon_refresh' Option Behavior

Is it possible for the PHP configuration option “remember_state_upon_refresh” to prevent the columns’ visibility, order, and width from being reset? We definitely need the option to reset/clear filters, default ordering and paging, but I find it really annoying to reconfigure columns visibility, columns positioning, and width every time we refresh the page with this option set to false. What do you think? Do we need another (new) option for this? I’m currently using this workaround for clearing (but it renders/loads/blinks the table twice, far from optimal):

<script>
	// workaround to clear filters and pagging when page loads (but do not clear column visibility, order, etc.)
	// Maybe you must have 'publish_events' => true in the PHP config file
	window.addEventListener('gcrud.datagrid.ready', () => {
		setTimeout(function() {
			document.querySelector(".grocery-crud .fa-eraser").click();
		}, 300);
	});
</script>

I may revisit that and have a new configuration probably.

Hello @bgeneto ,

I am glad to inform you that we have a new configuration with name remember_filters_upon_refresh at the newer version 3.0.14 which if it is set as false it is not remembering the filters only.

Let me know if that worked for you.

Regards
Johnny

1 Like

Hi, Johnny! Unfortunately it didn’t work for me. I’m getting error “We can’t process the response of the server. Not well JSON formatted response.” only when the new remember_filters_upon_refresh is set to false. Could you assist me in debugging it more? The message that follows is not very useful…

<div class="grocery-crud" data-api-url="/admin/banners/plataforma" data-landing-page-url="/admin/banners/plataforma" data-theme="bootstrap-v5"data-unique-id="53951e598xxxx7db2c8fe27f1xxxxxx" data-remember-filtering="false" data-publish-events="true">
    <div style="padding: 10px; border: 1px solid #aaa; border-radius: 10px;margin-bottom: 20px;display: none;" class="gc-hidden-message">
        Ooooops, something went wrong! If you can see this message, this is probably a misconfiguration in Grocery CRUD Enterprise!
    </div>

Hello @bgeneto ,

That’s weird. I will check it to see if there is a bug. In the meantime make sure that you have the configuration remember_filters_upon_refresh = false and make sure that you have remember_state_upon_refresh = true

Can you please ensure that you have both configurations and that the remember_state_upon_refresh is true ?

Also can you check from the network what error message you are getting?

Regards
Johnny

Hello @bgeneto ,

Unfortunately I can’t reproduce the issue that you have. Have you tried the above suggestion and see if that works for you?

Regards
Johnny

I’m having a lot of difficulty debugging this situation. In my vanilla installation of GCE (for testing purposes) everything works normally. But in production, using a custom bootstrap theme, the error appears. Nothing in the logs… the only thing that appears different in the network tab is two 303 (xhr / Redirect) - in the middle - containg a strange (to me) payload:

------WebKitFormBoundarywp12GvtqVmdJxUBx
Content-Disposition: form-data; name="action"

datagrid
------WebKitFormBoundarywp12GvtqVmdJxUBx
Content-Disposition: form-data; name="order_by"


------WebKitFormBoundarywp12GvtqVmdJxUBx
Content-Disposition: form-data; name="page"

1
------WebKitFormBoundarywp12GvtqVmdJxUBx
Content-Disposition: form-data; name="per_page"

10
------WebKitFormBoundarywp12GvtqVmdJxUBx
Content-Disposition: form-data; name="sorting"


------WebKitFormBoundarywp12GvtqVmdJxUBx--

action: datagrid
order_by: 
page: 1
per_page: 
sorting: 

And yes, I think my settings are ok (the same settings works in my the bare testing env.)

'optimize_sql_queries' => false,
'remember_state_upon_refresh' => true,
'remember_filters_upon_refresh' => false

The page/table loads, I can edit and add rows. But every time the page/table loads I get a modal saying:

We can't process the response of the server. Not well JSON formatted response.

Thanks anyway!

Hello @bgeneto ,

Thank you for your detailed report. Unfortunately I still can’t reproduce the issue. Just to make sure, if you have the configuration remember_filters_upon_refresh to true nothing of the above happens? Very weird :frowning:

Regards
Johnny

Also just making sure. You have removed the extra JavaScript with:

window.addEventListener(....

that you had right?

Regards
Johnny

That’s right. Removed (since the the clear filter button in yellow helped a lot).

Yes. No error with true.