Extjs 如何在Sencha cmd应用程序中获取网格(任何容器)引用?
我有一个简单的网格,其中有两个(添加和删除)按钮作为senchacmd应用程序中的停靠项。我想删除所选行 我在视图中将网格定义为Extjs 如何在Sencha cmd应用程序中获取网格(任何容器)引用?,extjs,sencha-cmd,Extjs,Sencha Cmd,我有一个简单的网格,其中有两个(添加和删除)按钮作为senchacmd应用程序中的停靠项。我想删除所选行 我在视图中将网格定义为 xtype:'app-main', viewModel: { type: 'main' }, layout: 'absolute', autoScroll : true, resizable:true, items: [ { xtype: 'gridpanel',
xtype:'app-main',
viewModel: {
type: 'main'
},
layout: 'absolute',
autoScroll : true,
resizable:true,
items: [
{
xtype: 'gridpanel',
x: 10,
y: 10,
autoScroll : true,
renderTo: document.body,
//height: 300,
width: 300,
title: 'Grid Panel',
store: 'peopleStore',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'id',
text: 'Id'
},
{
xtype: 'gridcolumn',
dataIndex: 'title',
text: 'Title'
},
{
xtype: 'gridcolumn',
dataIndex: 'body',
text: 'Body'
}
],
dockedItems: [{
xtype: 'toolbar',
items:[
{
xtype: 'button',
x: 330,
y: 10,
scale: 'medium',
text: 'Add New Record',
handler: function() {
var UserStore = Ext.getStore('peopleStore');
UserStore.add({title: 'asd', body:'asdasd'});
UserStore.sync();
UserStore.load();
}
},
{
xtype: 'button',
scale: 'medium',
text: 'Reset Records',
handler: function() {
//delete code will go here
}
}]
}]}]
带着这个问题
我知道代码是这样的
grid.getView().getSelectionModel().getSelection()[0];
if (selection) {
UserStore.remove(selection);
}
但是有人能告诉我如何获取对“网格”的引用吗?获取第一个父级(相对于按钮),这是一个网格:
xtype: 'button',
...
handler: function(button) {
var grid = button.up('gridpanel');
console.log("my grid", grid);
}
获取第一个父项(相对于按钮),该父项是一个网格,并且具有itemId“myGrid”(以防止歧义):
我强烈建议在ExtJS中查找选择器(对于ExtJS,非常感谢,它很有效。我还将浏览您提供的链接。
xtype: 'gridpanel',
itemId: 'myGrid',
...
xtype: 'button',
...
handler: function(button) {
var grid = button.up('gridpanel #myGrid');
console.log("myGrid", grid);
}