This is a migrated thread and some comments may be shown as answers.

Message Notification After Save and Update

13 Answers 2554 Views
Integration with other JS libraries
This is a migrated thread and some comments may be shown as answers.
surinder
Top achievements
Rank 1
surinder asked on 21 Feb 2013, 01:34 PM
Hi

After Save the data into data base using grid kendo ui, how to print the notification message on screen using Spring +kendo ui
How it possible and how can i do?


Thanks

13 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 25 Feb 2013, 07:50 AM
Hi Sutinder,

 
Basically you can use the requestEnd event of the DataSource to check if current operation is "update" or "create" and there is no errors to alert the user that the save operation is successful. Please check the example below:

Define requestEnd event handler:

<kendo:dataSource pageSize="20" requestEnd="onRequestEnd">
    <kendo:dataSource-transport>

JavaScript:
function onRequestEnd(e) {
    debugger;
    if (e.type == "update" && !e.response.Errors) {
        alert("Update record is successfull");
    }
 
    if (e.type == "create" && !e.response.Errors) {
        alert("Create record is successfull");
    }
}
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
surinder
Top achievements
Rank 1
answered on 26 Feb 2013, 05:11 AM
Hi Vladimir Iliev 
Its very help full code .its working fine with my project.
Kendo ui is very intractive ui and help full ui.


Thank you  very much.


Regards 
Surinder
0
surinder
Top achievements
Rank 1
answered on 26 Feb 2013, 11:09 AM
Hi,

   I m using spring mvc with kendo ui , How to return the error from  server side to ui side in grid .
   How to return error from the server to user


Thanks.
0
Vladimir Iliev
Telerik team
answered on 27 Feb 2013, 04:06 PM
Hi Surinder,

 
Using the "editing-inline" demo as a baseline I created small example about how to return errors from server and handle them using the error event on the client side. Please check the example below:

Example action (using the editing-inline demo for baseline):

@RequestMapping(value = "/editing-inline/update", method = RequestMethod.POST)
    public @ResponseBody Object update(@RequestBody Map<String, Object> model) {
        Product target = new Product();
         
        target.setProductId((int)model.get("productId"));
        target.setProductName((String)model.get("productName"));
        target.setUnitPrice(Double.parseDouble(model.get("unitPrice").toString()));
        target.setUnitsInStock((int)model.get("unitsInStock"));
        target.setDiscontinued((boolean)model.get("discontinued"));
        target.setCategoryId((int)model.get("categoryId"));
         
        try
        {
            //return random error for test purposes
            if(target.getUnitsInStock() == 15)
            {
                throw new Exception("There is error on server!");
            }
            product.saveOrUpdate(target);
             
            return target;
             
        }
        catch (final Exception e) {
             
            //create object that can be serialized to Json and include the error message
            HashMap<String, String> hashMap = new HashMap<String, String>() {{put("errors", e.getMessage());}};
             
            return  hashMap ;
        }
    }

Define the dataSource Error event handler:
<kendo:dataSource pageSize="20" error="errorHandler">

Configure the schema errors  field (in which field from the response the errors are expected):
<kendo:dataSource-schema errors="errors">

JavaScript:
function errorHandler(e){
    //debugger;
    alert(e.errors);
    setTimeout(function() {
        //refresh the grid
        e.sender.read();
    })
}
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michel
Top achievements
Rank 1
answered on 28 Feb 2013, 12:02 PM
I am using Kendo UI Web, and trying the solution below, but the e variable is not returning anything like that!

requestEnd: function(e) {
        kendoConsole.log("requestEnd: dsBusinessList: " + JSON.stringify(e));
        //debugger;
        if (e.type == "read" && e.response.Errors) {
            kendoConsole.log("Error Listing Businesses - Please Contact Site Administrator",true);
        }
    },     
and this is what the e is showing:-

{"sender":{"options":{"data":[],"schema":{"data":"data","errors":"Errors"},"serverSorting":false,"serverPaging":false,"serverFiltering":false,"serverGrouping":false,"serverAggregates":false,"sendAllFields":true,"batch":false,"transport":{"read":{"url":"api/business/list"},"destroy":{"type":"POST"}}},"_map":{},"_prefetch":{},"_data":[],"_ranges":[],"_view":[],"_pristine":[],"_destroyed":[],"_group":[],"_events":{"error":[null,null],"change":[null,null,null,null,null,null],"sync":[null],"requestEnd":[null],"progress":[null]},"transport":{"options":{"read":{"url":"api/business/list"},"destroy":{"type":"POST"}},"cache":{}},"reader":{},"_requestInProgress":false}}
there is nothing showing type of response or errors. 
I still need to know which call [read, update, destroy, add] is returning this error to be able to handle it
0
Vladimir Iliev
Telerik team
answered on 01 Mar 2013, 06:36 AM
Hi Michael,


From the provided information it's not clear for us what is the exact reason for this behavior - I would suggest to open a new support ticket and include the following details:

  • what is the exact version of KendoUI that is currently included in the project
  • what jQuery version is included in the project
  • provide your grid configuration
  • provide more information about the exact server-side technology used and the current code responsible for returning the data to the grid

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
surinder
Top achievements
Rank 1
answered on 06 Mar 2013, 12:52 PM
Hi,


   I want to save numeric values in grid using spring mvc and jsp.
How to show % with values in numeric text box in grid .

Thanks
 
0
surinder
Top achievements
Rank 1
answered on 06 Mar 2013, 12:57 PM
Hi,

How to return error from server to jsp page in spring MVC.

My server side code is this and how to return errors and message

@RequestMapping(value = "/productlocation/create.htm", method = RequestMethod.POST)
public @ResponseBody
List<ProductFromTo> create(
@RequestBody ArrayList<Map<String, Object>> models, Model modelmap) {
System.out.println("-----productlocation create----");
List<ProductFromTo> productFromTo = new ArrayList<ProductFromTo>();

for (Map<String, Object> model : models) {
ProductFromTo pt = new ProductFromTo();
ProductFromTo pt1 = new ProductFromTo();
System.out.println("from ::" + model.get("fromLocation"));
System.out.println("To ::" + model.get("toLocation"));
System.out.println("ProductId ::" + model.get("productId"));
System.out.println("productName ::" + model.get("productName"));

String pId = model.get("productId").toString();
String fId = model.get("fromLocation").toString();
String tId = model.get("toLocation").toString();

if (null != pId || null != fId || null != tId) {
Long productId = Long.valueOf(pId);
Long fromId = Long.valueOf(fId);
Long toId = Long.valueOf(tId);
if (fromId != toId) {
boolean status = iplPricingService.isProductLocationExist(
productId, fromId, toId);

if (status) {
modelmap.addAttribute("greetings",
"Location Already Exist Please try again!!");
System.out
.println("Location Already Exist Please try again!!");
productFromTo.add(null);
} else {
IPLPricing iplPricing = new IPLPricing();

Location fromLocation = locationService.get(Long
.valueOf(model.get("fromLocation").toString()));
iplPricing.setLocation(fromLocation);

Location toLocation = locationService.get(Long
.valueOf(model.get("toLocation").toString()));
iplPricing.setToLocation(toLocation);

Product p = productService.get(Long.valueOf(model.get(
"productId").toString()));
iplPricing.setProductIPL(p);

iplPricing.setType(ChargeType.MRC.getType());
iplPricingService.save(iplPricing);

IPLPricing iplPricing1 = new IPLPricing();
iplPricing1.setLocation(fromLocation);
iplPricing1.setToLocation(toLocation);
iplPricing1.setProductIPL(p);
iplPricing1.setType(ChargeType.NRC.getType());

iplPricingService.save(iplPricing1);

/**
* Add to product from to list
*/
pt.setFromLocation(""
+ iplPricing.getLocation().getLocationId());
pt.setToLocation(""
+ iplPricing.getToLocation().getLocationId());
pt.setProductName(iplPricing.getProductIPL()
.getProductName());
pt.setProductId(""
+ iplPricing.getProductIPL().getProductId());

productFromTo.add(pt);
pt1.setFromLocation(""
+ iplPricing1.getLocation().getLocationId());
pt1.setToLocation(""
+ iplPricing1.getToLocation().getLocationId());
pt1.setProductName(iplPricing1.getProductIPL()
.getProductName());
pt1.setProductId(""
+ iplPricing1.getProductIPL().getProductId());
productFromTo.add(pt1);
}

} else {
System.out("Product Location Are Same Plz Choose Different!!");
//FROM HERE HOW CAN I RETURN THE MESSAGE AND ERROR ON JSP
productFromTo.add(null);
}

}
}
return productFromTo;
}


Thanks

0
Vladimir Iliev
Telerik team
answered on 08 Mar 2013, 09:49 AM
Hi Surinder,

 
As I mention in my previous reply you can for example return HashMap containing the error message:

//create object that can be serialized to Json and include the error message
HashMap<String, String> hashMap = new HashMap<String, String>() {{put("errors", "Product Location Are Same Please Choose Different!!");}};
  
return  hashMap ;

 Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Anne
Top achievements
Rank 1
answered on 09 Apr 2013, 10:00 AM
Hi Michael/Vladimir,

Did you get any resolution to the problem where 'e' does not return anything in e.type?

I am facing same issue because of which not able to implement a simple thing i.e. showing a success message on delete of items from the grid.

Thanks,
Joydeep
0
Vladimir Iliev
Telerik team
answered on 11 Apr 2013, 07:49 AM
Hi Anne,

 
I would suggest to open a new suppot thread with more details about what exactly you are trying to achieve and more information about your current setup - that way we will be able to help you straight away.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Juan
Top achievements
Rank 1
answered on 21 Oct 2016, 09:42 PM

Hi Vladimir Iliev.

The e.type only return "read", but when i want to delete a row the alert(e.type) show me undefined. 

Can yo tell me how to resolve that. 

function onRequestEnd(e) {
            alert(e.type)
            debugger;
            if (e.type == "update" && !e.response.Errors) {
                alert("Update record is successfull");
            }

            if (e.type == "destroy" && !e.response.Errors) {
                alert("Create record is successfull");
            }
        };

0
Vladimir Iliev
Telerik team
answered on 24 Oct 2016, 07:39 AM
Hello Juan,


I tries to reproduce the described behavior when the "requestEnd" event does not contain the operation type but to no avail - the type is always available on our side. As this thread however is getting out of the original topic I would ask you to open new support thread / forum post and provide your current setup for further investigation. 

Regards,
Vladimir Iliev
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
Tags
Integration with other JS libraries
Asked by
surinder
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
surinder
Top achievements
Rank 1
Michel
Top achievements
Rank 1
Anne
Top achievements
Rank 1
Juan
Top achievements
Rank 1
Share this question
or