Jump to content
  • 0

How to display custom alert message if you have successfully added a record in tabular page using inline-add?


CapNcook

Question

Hi Everyone,

Is there a way we can display an alert message when we add a record? I have a lot of records in my tabular page and I have to scroll down to confirm if the records have been added so I was thinking it would be great if we have some alert message upon clicking the add button.  A green alert box with message success would be great functionality in our website. Any help would be appreciated! Thank you. 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hi,

For that one, you need to use a custom code. A combination of CSS and JS to be exact.

I have achieved this use-case using the following code.

1.) Add a header and footer in your result configuration.
2.) In the header add the following CSS code.
 

<style>
   .success-alert {
       background-color: #4CAF50;
            color: white;
            border: 1px solid #45A049;
            padding: 10px;
            text-align: center;
            font-weight: bold;
            position: fixed;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 300px; /* Adjust the width as needed */
        }
</style>

3.) In the footer add the following JS code.

<script type="text/javascript">
  const addButton = document.querySelector('.cbResultSetAddButton');

    addButton.addEventListener('click', function () {
        // Custom success message
        const successMessage = 'You have successfully added a record.';
        
        // Create an alert with a custom class
        const successAlert = document.createElement('div');
        successAlert.className = 'success-alert';
        successAlert.textContent = successMessage;

        // Add the alert to the body
        document.body.appendChild(successAlert);

        // Close the alert after 3 seconds (3000 milliseconds)
        setTimeout(function () {
            document.body.removeChild(successAlert);
        }, 3000);
    });
</script>

I have included comments to make it easier for you to modify as needed.


Example Result:


image.thumb.png.4ea31d8d245984439285d61ac89f2455.png

Hope this helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...