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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom message in the CRUD

Thread ID:

Created:

Updated:

Platform:

Replies:

125030 Jul 15,2016 02:08 PM UTC Jul 22,2016 11:23 AM UTC ASP.NET MVC 11
loading
Tags: Grid
Carlos Palomino
Asked On July 15, 2016 02:08 PM UTC

Dear,
How I can display a custom message that comes from Controller.cs when the operation CRUD is successful or fails?

Greetings.

Attachment: custom_message_crud_result_e94162ed.zip

Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 18, 2016 12:28 PM UTC

Hi Carlos,  
 
 Thanks for your interest in Syncfusion Products. 
We can show the custom message either in ActionComplete or ActionFailure event. ActionComplete event will be triggered after the CRUD operation is successful whereas the ActionFailure event will be triggered after the failure/exception in CRUD operation. So, if you would like to display and discriminate among the custom message of the success/failure, you can mention them in ActionComplete and ActionFailure separately. 
  
ActionComplete: 
 
Triggered for every grid action success event. For further Details refer this below documentation link. 
 
 
ActionFailure: 
 
Triggered for every grid action server failure event. For further Details refer this below documentation link. 
 
  

Please refer to the below code example.
 
 
<script type="text/javascript"> 
    function complete(args) { 
        if (args.requestType == "beginedit" || args.requestType == "delete" || args.requestType == "add" || 
 
args.requestType == "save" || args.requestType == "cancel")  // Condition for CRUD operations in action  
 
complete event to show the custom message.   
 
            alert("ActionComplete is triggered "); 
    } 
 
    function failure(args) { 
        if (args.requestType == "beginedit" || args.requestType == "delete" || args.requestType = "add" ||  
 
args.requestType == "save" || args.requestType == "cancel")  // Condition for CRUD operations in action  
 
failure event to show the custom message. 
 
            alert("ActionFailure is triggered "); 
    } 
 
</script> 
 

For your convenience, we have prepared a sample with the above solution which can be downloaded from the below location.

Sample Link:
http://www.syncfusion.com/downloads/support/forum/125030/ze/MvcApplication-588112179 
 
Regards, 
Thavasianand S.

Carlos Palomino
Replied On July 18, 2016 04:11 PM UTC

Hello such,
I need to show is a custom message that comes from controler.cs.

Greetings.

Jayaprakash Kamaraj [Syncfusion]
Replied On July 19, 2016 08:49 AM UTC

Hi Carlos,  
 
As per our understanding about your requirement, you would like to show a custom message from the server-side. We have also given solution based on that in our previous update. If your requirement is different please elaborate us your scenario to provide you a better solution.  
 
Jayaprakash K. 


Carlos Palomino
Replied On July 19, 2016 01:39 PM UTC

Hello,
The personalized message I want to send to View.chstml is from the controller.cs, either when the operation is failure or success.
I have been tested to assign a viewbag but not the message is displayed.

Greetings.

Jayaprakash Kamaraj [Syncfusion]
Replied On July 20, 2016 01:41 PM UTC

Hi Carlos, 

The args.responseText parameter in the actionFailure event returns the error message from the controller. We have already explained this solution to show the custom message from server-side in your other forum (124423 ). Please try the solution, which was suggested in that forum and we suspect given solution satisfies your requirement.  



If the provided solution is not what you have expected, please provide the following details,  

1.       Do you want to store error message in session variable and then display message? 
2.       Elaborate your actual requirement briefly. 
Regards, 
 
Jayaprakash K. 


Carlos Palomino
Replied On July 20, 2016 01:48 PM UTC

Hello such,
I want to store the customized message on a viariable of session or viewbag and display when the operacióin in the grid either failure or success.


Greetings.

Jayaprakash Kamaraj [Syncfusion]
Replied On July 21, 2016 01:47 PM UTC

Hi Carlos, 

We suspect that you would like to use a single variable throughout the application which will handle the exception thrown in any of the action in Grid or else in any other functionality of other elements. When some server-side actions failed in the Grid, we can handle them using the actionFailure event. Since it is an error method of Ajax Post, we cannot get a ViewData or ViewBag variables within them. So we suggest to use the session variables, which can be accessed anywhere in your application and can update the text of any element like updating the “divError” (in your case). Refer to the following code example. 

        public ActionResult DataSource(DataManager dm, bool? ckFlagTratt) 
        { 
            try 
            { 
                 . . . .. 
                      . ..  
                return Json(result, JsonRequestBehavior.AllowGet); 
 
            } 
            catch (Exception ex) 
            { 
                   . .. .  
                    . .. .  
                Session["Error"] = "Errore in loading"; 
                return RedirectToAction("GridFeatures", "Grid"); 
           } 
        } 
 
    function FailureMessage(args) {//actionFailure event of Grid 
        var Error = '@Session["Error"].ToString()'; 
        $("#divErrorView").text(Error).show(); 
           . . . 
               . . . 
   } 



Regards, 

Jayaprakash K. 


Carlos Palomino
Replied On July 21, 2016 02:20 PM UTC

Dear,
I downloaded the example and does not work.
In addition it can be used as in the case of success of CRUD.

Greetings.

Carlos Palomino
Replied On July 21, 2016 02:24 PM UTC

Dear,
I downloaded the example and does not work.
In addition it can be used as in the case of success of CRUD.
Messages should appear in a dialog.

Carlos Palomino
Replied On July 21, 2016 02:37 PM UTC

Attach images.

Attachment: document_f14f0518.zip

Jayaprakash Kamaraj [Syncfusion]
Replied On July 22, 2016 11:23 AM UTC

Hi Carlos, 
A support incident has been created under your account to resolve your requirement. Please log on to our support website to check for further updates.  
 
Regards,
Jayaprakash K. 


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.

Warning Icon 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.Close Icon

;