Automatic view refresh after deleting records

Hello,

We have a view with a grid which displays some contacts and in addition there is a button which calls « Send emails » method.

<grid title="Catalog Emails to Contacts" name="catalog-contact-email-grid" model="com.axelor.apps.crm.db.CatalogContactEmail" canNew="false" canEdit="false" canDelete="true" canSave="false">
    <toolbar>
        <button title="Send Email" name="Send Email" onClick="action-email-catalogs-contacts" showIf="batch != null" />
        <button title="Delete All Draft Emails" name="Delete All Draft Emails" onClick="action-delete-all-draft-emails" showIf="batch == null" />
    </toolbar>
    <field name="contact" />
    <field name="catalogLineList" />
    <field name="emailStatus" />
</grid>

After opening this view and pressing the button emails are sent correctly, no issue.

But if we try to delete some contacts from the grid using Delete button « Send Email » button no longer works and in addition it breaks Axelor I must press refresh on a browser to reload web page.

download-button

I’ve found a work around for this, after deleting the records pressing « Refresh » button (on the right from delete button) fixes this issue, « Send Email » button works.

Another issue is after deletion it shows incorrect number of items in a list (before deletion it showed 1 to 12 of 12) after deleting 5 records its showing 1 to 12 of 7.

item-count

  1. Does anyone know what could cause this issue?
  2. Is there a way to force a refresh after pressing delete button?

Thanks in advance.

  1. The issue is caused because you’re doing some work in the nack end but you never tell to your view that you deleted some elements. You need to tell to your view that some values have changed.

  2. Two solutions :

  • you can do response.setReload(true); in your controller
  • you can anwser to your view that data were edited (because some rows were deleted with response.setValues(your_list_with_your_contacts);