Reputation: 45074
What's the best way to put validation on a Dojo DataGrid cell? Among all the callbacks available, I haven't found any way to do it, not even a hacky way.
(I'm using Dojo 1.6.)
Upvotes: 0
Views: 1094
Reputation: 26
I suggest to create a button to apply/validate the data in the grid, call ajax with method PUT /{table}/{id} (-1) and json data item in the body.
var jsItem = JSON.stringify(jsonRestReflexion.newItem);
// function startAjax(xmlhttp, Url, callback, method, obj, headerName, headerValue)
ajaxhttp = startAjax(ajaxhttp ,jsonRestReflexion.getUrlRestFul()+jsonRestReflexion.newItem.id+"?query=validateEntity"
, callbackFromAjax, "PUT", jsItem
, "Content-Type", "application/json; charset=UTF-8");
Execute validation in the server and return error in the header
callbackFromAjax = function() {
//addDiv(portletId, this.responseText);
$("errorDetails").innerHTML = "Errors # " + this.getResponseHeader("ConstraintViolationsSize") + "<br/>"+ this.getAllResponseHeaders();
showDialog();
}
then open a dojo.dialog with error returning from the server with a close button or any error display implementation that you like.
I used the following technology:
good luck
Upvotes: 1