从 ExtJS 中的 GridPanel 获取模型
我有一个网格面板,允许对列进行内联编辑。此列使用组合框作为编辑器,“更改”事件和“选择”事件都没有为我提供可用于回溯编辑值以从网格面板获取更改行的内容。
我相信 Ext 会浮动编辑器的组合框,因此我无法执行诸如
combo.up()
返回网格之类的简单操作。
这是视图中的网格面板:
{
xtype: 'gridpanel',
title: 'Important Projects',
id: 'importantProjectsGrid',
dockedItems: [],
flex: 1,
columns: [
{ header: 'Quote Name', dataIndex: 'QuoteName', flex: 4 },
{ header: 'Quote Status', dataIndex: 'QuoteStatusID', flex: 6, editor: {
xtype: 'combobox',
editable: false,
action: 'QuoteStatus',
selectOnTab: true,
store: 'statuses',
queryMode: 'local',
displayField: 'Description',
valueField: 'Description'
} }
],
store: 'myimpprojects',
selModel: {
selType: 'cellmodel'
},
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})]
}
这是与此相关的控制器代码:
init: function () {
this.control({
'[action=QuoteStatus]': {
change: function (combo, new_value, old_value, opts) {
// I need to go back up from this combobox
// to get the row that this value was edited in
// to grab an ID value from that row's data
// in order to make an ajax request
}
}
});
},
感谢您的帮助!
I have a gridpanel that allows inline editing of a column. This column uses a combobox as the editor, and neither the "change" event nor the "select" event give me something usable to backtrace the edited value to get the changed row from the gridpanel.
I believe Ext floats the editor's combobox so therefore I can't do something simple like
combo.up()
To return to the grid.
Here is the grid panel from the view:
{
xtype: 'gridpanel',
title: 'Important Projects',
id: 'importantProjectsGrid',
dockedItems: [],
flex: 1,
columns: [
{ header: 'Quote Name', dataIndex: 'QuoteName', flex: 4 },
{ header: 'Quote Status', dataIndex: 'QuoteStatusID', flex: 6, editor: {
xtype: 'combobox',
editable: false,
action: 'QuoteStatus',
selectOnTab: true,
store: 'statuses',
queryMode: 'local',
displayField: 'Description',
valueField: 'Description'
} }
],
store: 'myimpprojects',
selModel: {
selType: 'cellmodel'
},
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})]
}
Here is the controller code pertaining to this:
init: function () {
this.control({
'[action=QuoteStatus]': {
change: function (combo, new_value, old_value, opts) {
// I need to go back up from this combobox
// to get the row that this value was edited in
// to grab an ID value from that row's data
// in order to make an ajax request
}
}
});
},
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以监控商店的
更新
事件。You can monitor store's
update
event.尝试将侦听器放在 CellEditing 插件上。
beforeedit
、edit
和validateedit
的事件接收包含对网格、记录、字段、行和列索引的引用的对象,等等。您应该能够检查事件处理程序中的组合框并从那里处理您的信息。文档页面的快速链接: Ext.grid.plugin.CellEditing
Try putting the listener on the CellEditing plugin. There are events for
beforeedit
,edit
, andvalidateedit
that receive an object containing references to the grid, the record, field, row and column indexes, and more. You should be able to check for the combobox in the event handler and handle your information from there.Quick link to the doc page: Ext.grid.plugin.CellEditing
我确信更新插件将通过底层存储的 api 自动处理更新,如果代理将 autoSync 设置为 true,则将数据自动发布到服务器。
配置代理的示例:
});
我会特别寻找两个配置:“autoSync”和“batchActions”
希望这可以帮助您进一步解决问题!
I'm convinced that the update plugin will handle the update automatically, through the api of the underlying store and post the data automatically to the server if the proxy as autoSync to true.
Example of the configured proxy:
});
I would look specially for the two configs: "autoSync" and "batchActions"
Hope this helps you further with your issue!