View Full Version : How to use validation response from server inside RowEditing plugin?

22 May 2012, 1:39 AM
I started to experiment with server-side validation of submitted data from RowEditing plugin in grid. However I am unable to find any info on how...
In docs (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.form.Basic-cfg-errorReader) is stated:
An Ext.data.DataReader (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.data.reader.Reader) (e.g. Ext.data.reader.Xml (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.data.reader.Xml)) to be used to read field error messages returned from 'submit' actions. This is optional as there is built-in support for processing JSON responses.
But how does the built-in support for processing JSON responses works? I tried without errorReader, sending back from server something like:
{"success":false, "errors":[{"my_field": "My error message"}]} after reading about errorReader I tried also with:
{"success":false, "errors":[{"id": "my_field", "msg": "My error message"}]} but no error is populated into the grid row I am editing. I tried also using the errorReader, and wrapped the grid into `Ext.form.Panel` like this:

Ext.define('FieldError', {
extend: 'Ext.data.Model',
fields: [{name: 'id', type: 'string'}, {name: 'msg', type: 'string'}]
Ext.define('Ext.form.Panel', {
errorReader: Ext.create('Ext.data.reader.Json', {
model: 'FieldError',
root: 'errors',
successProperty: 'success',
read: function(xhr) {
items: [{
xtype: 'grid',
store: 'someStore',
plugins: [Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1,
pluginId: 'editUserPlugin'})

But no error coming up either. What is the proper way then?
Thanks a lot for help!

25 May 2012, 11:49 AM
The error reader will only work if you are submitting the form which you probably aren't. The Ext.data.Operation has a getError method that should give you the error.

26 May 2012, 12:24 AM
Try this:

edit: function (editor, e) {
var form = editor.getEditor().getForm();

success: function () {
failure: function (record, operation) {
var errors = record.errors || operation.getError();
// Restart editing
editor.startEdit(record, 0);
// Show errors in editor form

14 Mar 2013, 12:18 PM
Even after i made the changes , the update button on the rowedit plugin is still updating the record. I have noticed that if i am doing any other validation (allowBlank etc) on the same field, then below custom validation is working else not .Am i missing something?

validateEditField: function (editor, e, eOpts) {
var newSIDValue=e.newValues.sid;

url: '/SSPA/SSPReview/ValidateSID',
method: 'GET',
params: {
sid: newSIDValue
success: function (response) {

if(response.responseText == 'Invalid SID') {

var form = editor.editor.getForm();
var field = form.findField('sid');
var markinv= field.markInvalid("Invalid SID");

e.cancel = true;

failure: function (response) {