简体   繁体   English

设置ExtJS.form.ComboBox的值

[英]Set value for ExtJS.form.ComboBox

I have an Ext.grid.EditorGriPanel which has an combobox editor in its columnModel (the store of combox has just only 2 items: enabled/disabled). 我有一个Ext.grid.EditorGriPanel,它的columnModel中有一个组合框编辑器(combox的存储区只有2个项目:启用/禁用)。 When a new blank row is inserted to grid, I want the combobox in that column have to be set to a default value (enabled), and the dropdown is not expanded. 当新的空白行插入到网格中时,我希望该列中的组合框必须设置为默认值(启用),并且下拉列表不展开。 I've tried to use grid.colModel.columns[2].editor.select(0) to get the combobox editor and set "enabled" value for it, but it did not work. 我尝试使用grid.colModel.columns[2].editor.select(0)来获取组合框编辑器并为其设置“启用”值,但是它不起作用。 Another way is using grid.colModel.columns[2].getCellEditor(rowIndex) , but it returns an EditorGrid (I was so surprised because the ExtJS 3.3.1 API doesn't have this component). 另一种方法是使用grid.colModel.columns[2].getCellEditor(rowIndex) ,但是它返回一个EditorGrid(我很惊讶,因为ExtJS 3.3.1 API没有此组件)。 Could you please help me on this problem? 您能帮我解决这个问题吗? Thank you so much! 非常感谢!

When a new blank row is inserted to grid, I want the combobox in that column have to be set to a default value (enabled), and the dropdown is not expanded. 当新的空白行插入到网格中时,我希望该列中的组合框必须设置为默认值(启用),并且下拉列表不展开。

When the new record is inserted to the grid's store , the value of your column (in the record) needs to be set to "enabled". 当新record插入到网格的store ,您的列(在记录中)的值需要设置为“已启用”。 I'm not sure if you are doing it like this currently? 我不确定您当前是否正在这样做? In other words, the value must not be set to the editor of the column. 换句话说,不得将值设置为列的editor Set it directly in the record. 直接在记录中设置。

(Also, you can define default values to be used for all records using the recordType property of the store - see ExtJS API documentation for more details - but this is optional.) (此外,您可以使用商店的recordType属性定义用于所有记录的默认值-有关更多详细信息,请参见ExtJS API文档 -但这是可选的。)

Finally, note that the combobox will not be displayed immediately after the row is added. 最后,请注意,添加行后,组合框不会立即显示。 The combobox is displayed only when you start editing that particular cell - this is the way EditorGrid works in ExtJS. 仅当您开始编辑特定单元格时,才会显示组合框-这是EditorGrid在ExtJS中的工作方式。 But at least you should get the new row to immediately display the correct value ("enabled") with this advice. 但是至少您应该获得新的行,以便根据此建议立即显示正确的值(“启用”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM