13 Answers, 1 is accepted
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"
);
}
}
Vladimir Iliev
the Telerik team

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

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.
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();
})
}
Vladimir Iliev
the Telerik team

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
);
}
},
{"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}}
I still need to know which call [read, update, destroy, add] is returning this error to be able to handle it
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
Vladimir Iliev
the Telerik team

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

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
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

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
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.
Vladimir Iliev
the Telerik team

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");
}
};
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