grid

function getCUInstance()
{
document.getElementById("title1").innerHTML = "My VM Instances";
document.getElementById("content1").innerHTML = "";
Ext.QuickTips.init();

function changeStatus(val)
{
if (val == 0)
{
return '<span style="color:green;">pending</span>';
} else if (val == 1)
{
return '<span style="color:green;">running</span>';
}else if(val == 2)
{
return '<span style="color:green;">destroyed</span>';
}else{
return '<span style="color:green;">exception</span>';
}
}

//define model
Ext.define('ShowProductInstance', {
extend: 'Ext.data.Model',
fields: [
{name: 'productinstanceInstanceId', type: 'string'},
{name: 'productinstanceAliasName', type: 'string'},
{name: 'public_addresses', type: 'string'},
]
});

//loading data
var myStore = Ext.create('Ext.data.Store', {
model: 'ShowProductInstance',
proxy: {
type: 'ajax',
url : 'vm!vmInstance.action',
reader: {
type: 'json',
root: 'showProductInstance'
}
}
});

var grid = Ext.create('Ext.grid.Panel', {
//title: 'Company data',
store: myStore,
columns: [
{
header:'id',
id:'productinstanceInstanceId',
text:'productinstanceInstanceId',
hidden:true,
width:100,
dataIndex: 'productinstanceInstanceId'
},
{
header:'status',
text:'productinstanceStatus',
width:80,
sortable : true,
renderer:changeStatus,
dataIndex: 'productinstanceStatus'
},
{
header:'product',
xtype: 'actioncolumn',
width: 100,
items: [
{
icon:'../../resources/css/images/stoppic.png', // Use a URL in the icon config
tooltip:'stop instance',
handler:function(grid, rowIndex, colIndex)
{
var instance = myStore.getAt(rowIndex);
alert("id: " + instance.get('productinstanceInstanceId'));
}
},
{
icon:'../../resources/css/images/deletepic.png', // Use a URL in the icon config
tooltip:'delete instance',
handler:function(grid, rowIndex, colIndex)
{
var instance = myStore.getAt(rowIndex);
alert("id: " + instance.get('productinstanceInstanceId'));
}
}
]
}

]
});
myStore.load();
grid.render("content1");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值