We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Custom Success/Info/Error Messages

Thread ID:

Created:

Updated:

Platform:

Replies:

124379 Jun 6,2016 04:33 AM Jun 7,2016 02:16 PM ASP.NET MVC 1
loading
Tags: Grid
Arthur
Asked On June 6, 2016 04:33 AM

Hello,

iam using the Grid with CRUDURL for Editing. How to alert the Client with custom send Messages from the Controller? How to pass a Message to a JS-Function from the Controller?

".ClientSideEvents(cse=>cse.EndEdit("alertOK"))"

function alertOK(args, msg) {
            toastr.success(msg);
        }

C#-Controller:

 public ActionResult CrudUpdate(Mitarbeiter value, string action)
        {
            if (action== "update")
            {
                cont.Entry(value).State = EntityState.Modified;
                cont.SaveChanges();
                return Json(????):
            }


Prasanna Kumar Viswanathan [Syncfusion]
Replied On June 7, 2016 02:16 PM

Hi Arthur, 

Thank you for contacting Syncfusion support. 

To pass a message to the client from the controller, use the custom adaptor in the grid. In the custom adaptor, the processResponse has to be overridden to process the data from the server. We have extended processResponse method of the ej.UrlAdaptor and in the extended method we display the alert message. 
 
The custom adaptor has been assigned in the grid Load event. 
 
Find the code example and sample: 
 
 
@(Html.EJ().Grid<object>("Grid") 
         .Datasource(ds => ds.URL("/Home/DataSource").Adaptor("UrlAdaptor").CrudURL("/Home/Update")) 
        .EditSettings(edit => { edit.AllowEditing().AllowAdding().AllowDeleting(); }) 
         .AllowPaging() 
        .ToolbarSettings(toolbar => 
            { 
                toolbar.ShowToolbar().ToolbarItems(items => 
                { 
                    items.AddTool(ToolBarItems.Add); 
                    items.AddTool(ToolBarItems.Edit); 
                    items.AddTool(ToolBarItems.Delete); 
                    items.AddTool(ToolBarItems.Update); 
                    items.AddTool(ToolBarItems.Cancel); 
                }); 
            }) 
         .Columns(col => 
        { 
-------------------------------------------- 
        }) 
        .ClientSideEvents(eve => { eve.Load("load"); }) 
) 
 
<script type="text/javascript"> 
 
    function load(args) { 
        this.model.dataSource.adaptor = new customAdaptor(); 
    } 
        var customAdaptor = new ej.UrlAdaptor().extend({ 
 
            processResponse: function (data, ds, query, xhr, request, changes) {               
                if (data.success != undefined) 
                    alert(data.success); 
                var obj = ej.UrlAdaptor.prototype.processResponse(data, ds, query, xhr, request, changes); 
                return obj;                    
            }, 
        }); 
</script> 
 
------------------------------------------------------------------------ 
public ActionResult Update(EditableOrder value) 
        { 
            OrderRepository.Update(value); 
            var data = OrderRepository.GetAllRecords(); 
            if (value.Freight != null) 
                return Json(new { result = data, success = "success" }, JsonRequestBehavior.AllowGet); 
            else 
                return Json(new { result = data, success = "failure" }, JsonRequestBehavior.AllowGet); 
        } 
 
 
 
Regards, 
Prasanna Kumar N.S.V 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;