Notification on success or failed when insert data

first of all, im sorry for asking to many question 

is there is way to show notification success or failed when insert data ? 


1 Reply

UA Udhayakumar Anand Syncfusion Team May 24, 2023 03:45 AM UTC

Muqaffi,


Greetings from Syncfusion.


We have achieved your requirement by using a “CustomAdaptor” which is extended from an “UrlAdaptor”.


To help you get started, we have prepared a sample that demonstrates how to trigger the alert method when the data source is successfully fetched and during editing. This will allow you to show notifications for successful or failed data insertion.


Please find the sample attached. It includes detailed code examples and instructions on how to integrate this functionality into your project.



Code Snippet:

/*index.cshtml*/

@(Html.EJS().Gantt("Gantt")   ……/////

.Created("Created")

<script type="text/javascript">

    function Created(args) {

        // extending the default UrlAdaptor 

        class CustomAdaptor extends ej.data.UrlAdaptor {

            processResponse(data, ds, query, xhr, request, changes) {

                if (!ej.base.isNullOrUndefined(data.message)) {

                    alert(data.message);

                } else {

                    alert("data not fetched properly");

                }

                if (!ej.base.isNullOrUndefined(data.data))

                    return data.data;

                else

                    return data;

            }

        }

        var grid = document.getElementsByClassName('e-gantt')[0].ej2_instances[0]

        grid.dataSource = new ej.data.DataManager({

            url: "/Home/UrlDatasource",

            batchUrl: "/Home/BatchUpdate",

            adaptor: new CustomAdaptor()

        });

    }

</script>

 

[Server side code]

 

public ActionResult UrlDatasource( DataManagerRequest dm)

   {

      …….//////

     string msg = "Successfully Data fetched";

            return dm.RequiresCounts ? Json(new { result = DataList, count = count, message = msg }) : Json(DataList);

 

public ActionResult BatchUpdate(CRUDModel batchmodel) {

      ……//////

      string msg = "Successfully performed editing the record";  //Message from server

            return Json(new { addedRecords = batchmodel.Added, changedRecords = batchmodel.Changed, deletedRecords = batchmodel.Deleted, message = msg });

}


Sample Link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/alert_msg_mvc-1700235609


Otherwise, Gantt events such as ActionComplete and ActionFailure events also triggered for successful Gantt action and also on fail. You can show notification message with the help of this events.


We hope that this solution meets your needs. If you have any further questions or require additional assistance, please don't hesitate to reach out to us.


Regards,

Udhayakumar


Loader.
Up arrow icon