Validating RowEditor data in ExtJS 4

I developed an application based on the MVC pattern. Therefore, I also defined my proxies, fields, and validators in my model. For example, a model for a list of countries:

Model

Ext.define('LT.model.Country',{ extend: 'Ext.data.Model', fields: [{name: 'id',type: 'int'}, {name: 'name', type: 'string'}, ], validations: [ {type: 'length', field: 'name', min: 2} ], proxy: { type: 'rest', url: '/country', reader: { type: 'json' }, writer: { type: 'json' } } }); 

And here is the store for using this model:

Store:

 Ext.define('LT.store.Country', { extend: 'LT.base.store.Base', model: 'LT.model.Country' }); 

The repository is displayed in a panel with a grid , where I use the RowEditor plugin to turn on and edit rows directly in a grid

Panel Mesh:

  Ext.define('LT.view.country.List' ,{ extend: 'Ext.grid.Panel', alias : 'widget.country-list', plugins: [ Ext.create('Ext.grid.plugin.RowEditing', { clicksToEdit: 2, clicksToMoveEditor: 1 }) ], store : 'Country', columns: [ {header: 'ID', dataIndex: 'id', width: 50}, {header: 'Name', dataIndex: 'name', flex: 3, editor: 'textfield'}, ], tbar: [{ xtype: 'button', action: 'add', text: 'Add' },{ xtype: 'button', action: 'delete', text: 'Delete' }] }); 

Now my problem is that validation errors do not appear if you are editing data in grid mode. If the data does not meet the verification criteria, then they are not transmitted by the proxy (this is normal), but the user also does not receive an error message that the inserted data is invalid.

I found some (not very pretty) workarounds - but maybe someone knows a different solution for adding validation functions in rowjiting in extjs?

Thanks in advance and welcome Michael

+4
source share
1 answer

Integration of Ext.grid.panel and Ext.data.Model.validations validation

The answer above talks about an approach you can follow

+2
source

Source: https://habr.com/ru/post/1393591/


All Articles