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. Image for the cookie policy date
close icon

Custom message in the CRUD

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

11 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team 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.


CP Carlos Palomino July 18, 2016 04:11 PM UTC

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

Greetings.


JK Jayaprakash Kamaraj Syncfusion Team 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. 



CP Carlos Palomino 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.


JK Jayaprakash Kamaraj Syncfusion Team 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. 



CP Carlos Palomino 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.


JK Jayaprakash Kamaraj Syncfusion Team 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. 



CP Carlos Palomino 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.


CP Carlos Palomino 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.


CP Carlos Palomino July 21, 2016 02:37 PM UTC

Attach images.

Attachment: document_f14f0518.zip


JK Jayaprakash Kamaraj Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon