-
10 Dec 2012 9:41 PM #1
Unanswered: container control as a grid editor does not update values
Unanswered: container control as a grid editor does not update values
So I have a grid with two columns, the first has just text, the second
needs to have a custom control (with a checkbox and a combo box)
When I click update to update the row. The first column gets updated,
but the second column doesn't
This is how it looks:
grid.PNG
I naively added a getValue() into my custom control but no luck!! (Note: I'm using row editing plugin)
Here is my code,
The reportpopulation is the custom control here. Here is the code forCode:Ext.define('MainGrid', { extend: 'Ext.grid.Panel', //defs for all the toolbars and buttons plugins: [rowEditing], columns: [ { xtype: 'rownumberer' }, { xtype: 'gridcolumn', text: 'Column Titles', dataIndex: 'ColumnTitle', editor: { xtype: 'textfield', } }, { xtype: 'gridcolumn', sortable: false, align: 'center', dataIndex: 'IssueCondition', editor: { xtype: 'reportpopulation' }] });
it:
So clicking Update doesn't :Code:Ext.define('SelectPopulation', { extend: 'Ext.container.Container', itemId: 'ctrSelectpopulation', alias: 'widget.reportpopulation', layout: { type: 'hbox' }, initComponent: function () { //code to add combo box and checkbox snipped .... }, getValue: function () { //This doesn't work! return "Booo"; } });
1.. Is there something I'm missing?
2.. Should I inherit from FieldBase?
-
12 Dec 2012 3:04 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
To make something a form you need to do different things. Here is an example:
Code:Ext.define('MyField', { extend : 'Ext.container.Container', xtype : 'myfield', isFormField : true, name : null, value : null, constructor : function(config) { config = config || {}; if (config.value) { this.html = config.value; } else if (this.value) { this.html = this.value; } this.callParent([config]); }, setValue : function (value) { this.value = this.html = value; }, getValue : function() { return this.value; }, getName : function() { return this.name; }, getSubmitData : function() { var data = {}; data[this.getName()] = this.getValue(); return data; }, isValid : function() { return true; }, validate : function() { return this.isValid(); }, isFileUpload : function() { return false; } }); new Ext.form.Panel({ renderTo : document.body, url : 'data/form.php', items : [ { xtype : 'textfield', fieldLabel : 'Text', name : 'text', value : 'foo' }, { xtype : 'myfield', name : 'test', value : 'bar' }, { xtype : 'button', text : 'Get Values', handler : function (btn) { var form = btn.up('form'); console.log( form.getValues() ); } }, { xtype : 'button', text : 'Submit', handler : function (btn) { var form = btn.up('form'); form.submit(); } } ] });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote