javascript - Form Validation isn't working in ExtJS -
i tried add validation form using formbind: true
the validation isn't occuring though (the save button not greyed out). validation text field not blank occuring, binding save button seems nothing.
if double click record show form in question. can seen here:
http://jsfiddle.net/byronaltice/7yz9oxf6/32/
code below in case can't access jsfiddle:
ext.application({ name: 'myapp', launch: function () { //popup form items in grid panel ext.define("sessionform", { extend: 'ext.window.window', alias: 'widget.sessionform', padding: 5, width: 600, title: 'edit sessions', model: 'true', items: [{ xtype: 'form', bodypadding: 10, title: '', items: [{ xtype: 'textfield', name: 'title', fieldlabel: 'title', labelwidth: 90, defaults: { labelwidth: 90, margin: '0 0 10 0', anchor: '90%' }, allowblank: false }, { xtype: 'checkboxfield', name: 'approved', fieldlabel: 'approved' }] }, { xtype: 'container', padding: '10 10 10 10', layout: { type: 'hbox', align: 'middle', pack: 'center' }, items: [{ xtype: 'button', text: 'save', formbind: 'true', margin: '5 5 5 5', handler: function (button) { var form = button.up().up().down('form'); form.updaterecord(); button.up('window').destroy(); } }, { xtype: 'button', text: 'cancel', margin: '5 5 5 5', handler: function (button) { button.up('window').destroy(); } }] }] }); //the grid panel area ext.define("sessiongridpanel", { extend: 'ext.grid.panel', alias: 'widget.sessiongridpanel', listeners: { itemdblclick: function (gridpanel, record, item, e) { var formwindow = ext.create('sessionform'); formwindow.show(); var form = formwindow.down('form'); form.loadrecord(record); } }, store: { fields: [ 'id', { name: 'title', sorttype: 'asuctext' }, 'approved', { dateformat: 'c', name: 'sessiontimedatetime', sorttype: 'asdate', type: 'date' }, { convert: function (v, rec) { var convertit = ext.util.format.daterenderer('m/d/y g:i a'), pretty = convertit(rec.get("sessiontimedatetime")); return pretty; }, name: 'sessiontimepretty', type: 'string' }], autoload: true, autosync: true, data: [{ id: 101, sessiontimedatetime: '2014-08-27t21:00:00.000+0000', title: 'js d', approved: true }, { id: 102, sessiontimedatetime: '2014-10-27t22:30:00.000+0000', title: 'cs s', approved: false }, { id: 105, sessiontimedatetime: '2014-09-27t20:30:00.000+0000', title: 'xxtjs e', approved: false }, { id: 104, sessiontimedatetime: '2014-09-26t22:00:00.000+0000', title: 'zxxtjs e', approved: true }, { id: 103, sessiontimedatetime: '2014-09-26t22:00:00.000+0000', title: 'extjs e', approved: true }], sorters: [{ property: 'title' }], groupfield: 'sessiontimedatetime' }, columns: [{ xtype: 'gridcolumn', dataindex: 'id', text: 'id' }, { xtype: 'gridcolumn', dataindex: 'title', text: 'title', flex: 1, minwidth: 100, width: 75 }, { xtype: 'gridcolumn', dataindex: 'approved', text: 'approved' }, { dataindex: 'sessiontimepretty', text: 'session start time', width: 180 }], features: [{ ftype: 'grouping', groupheadertpl: [ '{[values.rows[0].get(\'sessiontimepretty\')]} (session count: {rows.length})'] }] }); ext.create('ext.container.viewport', { layout: { type: 'border' //align: 'stretch' }, items: [{ region: 'west', layout: { type: 'vbox', align: 'stretch' }, flex: 1, split: true, items: [{ xtype: 'sessiongridpanel', flex: 1 }, { xtype: 'splitter', width: 1 }, { html: '<b>speakers panel</b>', flex: 1, xtype: 'panel' }] }, { region: 'center', html: '<b>details panel</b>', flex: 1, xtype: 'panel', title: 'details panel', collapsible: true, collapsed: true, collapsedirection: 'right' }] }); } });
from sencha api documentation:
any component within formpanel can configured formbind: true.
the problem using attribute formbind outside form component
you can correct code in way:
ext.define("sessionform", { extend: 'ext.window.window', alias: 'widget.sessionform', // ... items: [{ xtype: 'form', items: [{ // form items }], buttons: [{ xtype: 'button', text: 'save', formbind: true, handler: function (button) { // should rewrite following line // make independant components structure var form = button.up().up().down('form'); form.updaterecord(); button.up('window').destroy(); } }, { xtype: 'button', text: 'cancel', handler: function (button) { button.up('window').destroy(); } }] }] }); your fiddle changed: http://jsfiddle.net/7yz9oxf6/34/
Comments
Post a Comment