[英]extjs 4: list view select image id and display the image on other panel
[英]How to select an Extjs grid by Id and display it on the panel
我創建了一個包含數據的數組,一個包含此數據的存儲區和一個網格。 所有這些都存在於回調ajax函數中(帶有數據的數組是POST請求的響應)。
var ajaxurl = 'requests/requestKomvus.php', // script to run
data = {datastr:datastr}; // data to pass
$.post(ajaxurl, data, function (response) {
var myData = [
['Company1',71.72,0.02],
['Company2',29.01,0.42],
['Company3',83.81,0.28],
['Company4',52.55,0.01]
];
var store = new Ext.data.ArrayStore({
fields: [
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
]
});
store.loadData(myData);
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columns: [
{id:'company',header: "Company", width: 160, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, dataIndex: 'price'},
{header: "Change", width: 75, sortable: true, dataIndex: 'change'},
],
stripeRows: true,
height:940,
width:500
});.... //end of ajax request
我想要的是在我的items元素中獲取“ grid”變量:
items: [{
xtype: 'panel',
title: 'Images',
items: [{contentEl:'img',autoScroll:true, height:940 }],
},{
xtype: 'panel',
title: 'Material',
items: [{contentEl:'msg',autoScroll:true,height:940 }]
},
{
xtype: 'panel',
title: 'Check',
items: [grid], //// how to put it here?
}]
}],renderTo : Ext.getBody()
是否有一些使用extjs的直接方法? 例如,在我的網格中定義一個ID,然后獲取具有該ID的變量?
重新閱讀問題后。 首先,在AJAX調用之外聲明所有內容。 在外部聲明存儲,數據和網格。 然后,在面板中,您只需將網格放在items數組上:
var store = ....
var grid = ...
// ...
{
xtype: 'panel',
title: 'Check',
items: [
grid
]
}
如果需要在AJAX請求中更新網格數據,則可以像現在一樣通過調用loadData來完成。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.