Hi,
[ In SmartClient version 5.7 RC1 ]
We are using an editable ListGrid with server side data.( We have configured the Datasource xml and server object mappings).
We have a problem during delete. The ‘reomoveSelectedData()’ is working fine in normal cases.
But if i have sent some server side validation failure messages, then curresponding row is not displaying the error messages. ( But the validation server side validation messages are getting displayed properly in add/update)
The Server Action class remove method contains the following code..
dsResponse.addError("domain","Cannot Delete. The selected Domain is associated with Node Profile(s)");
I can see the following in developer consolewhich clearly shows the error messages from server. But the field ‘domain’ is not showing the error message in list grid.
17:45:48.985:INFO:RPCManager:transaction 2 arrived after 381ms
17:45:49.077:DEBUG:RPCManager:Result string for transaction 2: "//isc_RPCResponseStart-->[
{
errors:[
{
domain:{errorMessage:"Cannot Delete. The selected Domain is associated with Node Profile(s)"}
}
],
invalidateCache:false,
data:null,
status:-4,
isDSResponse:true
}
]//isc_RPCResponseEnd"
17:45:49.153:INFO:RPCManager:rpcResponse(domain_remove)[remove]: [status=-4], result: object
Hi Mahen,
Unlike saving edits in a grid, the removeSelectedData() method will not automatically show server-generated validation errors for the removed row. This is a feature we may be adding at some point, but in the mean time the best thing to do here is to add a callback to your removeSelectedData call which will display the validation error to the user.
Something like:
myGrid.removeSelectedData(
function (response, data, request) {
if (response.status== -4) {
var errors = response.errors,
errorString = "Server generated error on delete:";
for (var fieldName in errors) {
errorString += "<br>" + fieldName + ": "
+ errors[fieldName].errorMessage;
}
isc.warn(errorString);
}
}
);
Callback is not getting called after validation error from server
Hi,
I have tried the callback as you said. Still it is not working as expected..
The callback is being called only after the successful remove happens.
In the case of validation error message from the server this callback is not being called.
you said
the removeSelectedData() method will not automatically show server-generated validation errors for the removed row
If a row is successfully removed from server it will be removed from the client(ListGrid)..
there is no problem with this..
But due to some validaion failure if the row is yet removed from the server… then i won’t return the primary key or the entire object from the server.. [means i won’t call dsResponse.setData() in server ]
In this case the row will not be deleted from the client(ListGird) also.
If this is the case then , we can have the feature like
. The error message will be shown in the corresponding fields.
This will be heplful in the case of multiple row delete operation also.
We need a userfriendly way to display the validation failure in the case of delete operaion..
Can you help me..
Thanks
Validation errors within a ListGrid have a quite specific meaning – they imply that the current edit value for the field in question is not valid to be saved.
For this reason we don’t really expect to get validation errors returned from the server on a delete attempt (in this case there are no edit values for the row in question), and our logic doesn’t handle displaying them.
I’m sorry for the confusion with the callback approach - Not sure why this isn’t working for you off the top of my head, but I’ll investigate a little offline to make sure everything is working as it should be.
Regardless a more “correct” way to handle this is actually slightly different - rather than setting validation errors on the DSResponse, you should be able to set an error code, and set the response to a string.
This string will then be displayed to the user in a warn dialog when it’s returned to the client. Or you can apply some custom error handling to do something else with the response if you prefer.
See the “Error Handling” section under the RPCManager class overview for more on this.