//var time ="";
//var geoIds = "";
//var methodIndex = 2;
//var typeStr;
ResGrid = Ext.extend(Ext.grid.GridPanel, {
constructor : function(cfg) {
//copy 参数属性到当前对象
var cfg = cfg || {};
Ext.apply(this, cfg);
var data=[
['10.21.34.56','华为设备','5680','aa','1','1'],
['10.21.34.56','中兴设备','C200','aa','2','1'],
['10.21.34.56','烽火设备','AN5616','aa','2','2'],
['10.21.34.56','贝尔设备','AN5616','aa','0','2'],
['10.21.34.56','贝尔设备','AN5616','aa','3','3'],
['10.21.34.56','贝尔设备','AN5616','aa','3','3'],
['10.21.34.56','贝尔设备','AN5616','aa','3','3']
];
this.store=new Ext.data.Store({
autoLoad : true,
proxy:new Ext.data.MemoryProxy(data),//获得本地数据
//proxy:new Ext.data.ScriptTagProxy({url:'http://www.baidu.com'}),//获得远程数据
reader:new Ext.data.ArrayReader( //解析数据
{},
[
{name:'oltIp'},
{name:'oltName'},
{name:'oltType'},
{name:'softVersion'},
{name:'synchronstate'},
{name:'state'}
]
)
});
//这里设置根据条件禁用选中
this.sm=new Ext.grid.CheckboxSelectionModel({
singleSelect : false,
dataIndex:"id",
listeners:{'beforerowselect': function( SelectionModel, rowIndex, keepExisting,record ) {
if((record.data.synchronstate)=='1'){ //同步状态
//Ext.Msg.alert("提示信息","当前记录已经发布,无法再修改或发布!");
//SelectionModel
return false; //不能进行选择
}else{
return true;
}
}}
}),
// this.timeField = new Ext.form.TextField({
// id:'_timeRange',
// width : 160
// });
// var date = new Date();
// date.setDate(date.getDate()-1);
// time = date.format("Ymd");
// this.timeField.setValue(time);
// this.areaCombo = new Ext.ux.form.LovCombo( {
// width : 160,
// editable : false,
// valueField : "geoid",
// displayField : "geoname",
// mode : 'local',
// selectAllOn:true,
// triggerAction : 'all',
// allowBlank : true,
// emptyText : '请选择',
// store: new Ext.data.Store({
// proxy : new Ext.data.HttpProxy({url : 'allArea.action',method : 'POST'}),
// reader : new Ext.data.JsonReader({}, [
// {name : 'geoid'}, {name : 'geoname'}
// ])
// })
// });
// this.areaCombo.store.load();
this.areaCombo = new Ext.ux.form.LovCombo({
id:'id',
emptyText: "请选择...",
isFormField: true,
width : 100,
mode: 'local',
allowBlank:false,//不允许为空
blankText:"不能为空",//
forceSelection: true,
triggerAction: 'all',
displayField:'text',
listWidth:100,
valueField:'id',
store:new Ext.data.SimpleStore({
data : [['1', '合肥'],['2', '芜湖'],['3', '安庆'],['4', '蚌埠']],
fields : ['id', 'text']
}),
readOnly: true
});
this.factoryCombo = new Ext.ux.form.LovCombo({
id:'facid',
emptyText: "请选择...",
isFormField: true,
width : 100,
mode: 'local',
allowBlank:false,//不允许为空
blankText:"不能为空",//
forceSelection: true,
triggerAction: 'all',
displayField:'text',
listWidth:100,
valueField:'id',
store:new Ext.data.SimpleStore({
data : [['1', '中兴'],['2', '华为'],['3', '烽火'],['4', '贝尔']],
fields : ['id', 'text']
}),
readOnly: true
});
ResGrid.superclass.constructor.call(this, {
title : '资源同步信息',
region :'center',
border : false,
split:true,
loadMask : {
msg : '正在载入数据,请稍候...'
},
cm: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),this.sm,
{header : 'OLTIP', dataIndex :'oltIp', align : 'center', width: 100, sortable: true},
{header : 'OLT名称', dataIndex : 'oltName', align : 'center', width: 240, sortable: true},
{header : 'OLT设备型号', dataIndex : 'oltType', align : 'center', width: 100, sortable: true},
{header : '软件版本', dataIndex : 'softVersion',align : 'center', width: 100, sortable: true},
{header : '同步状态', dataIndex :'synchronstate', align : 'center', width: 100, sortable: true, renderer:this.rendererFlag},
{header : '设备状态', dataIndex :'state', align : 'center', width: 100, sortable: true, renderer:this.rendererstate}
]),
bbar: new Ext.PagingToolbar({
pageSize : 5,
store : this.store,
firstText : '第一页',
nextText : '下一页',
prevText : '上一页',
refreshText : '刷新',
lastText : '最后一页',
beforePageText : '当前',
afterPageText : '页/共{0}页',
displayInfo : true,
displayMsg : '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
doLoad:function(C){ //为了点击下一页传递参数用
var B={};
A=this.paramNames;
B[A.start]=C;
B[A.limit]=this.pageSize;
// B['times']=time;
// B['typeStr']=typeStr;
// B['geoIds']=geoIds;
// B['methodIndex']=methodIndex;
if(this.fireEvent("beforechange",this,B)!==false){
this.store.load({params: B});
}
},
emptyMsg : "没有记录",
items:[' ','-',
/*{text : '修改', iconCls: 'update', handler: this.doUpdate, scope: this}, '-',
{text : '删除', iconCls: 'delete', handler: this.doDelete, scope: this}, '-',*/
{text : '提交任务', iconCls: 'excel', handler: this.doExport, scope: this}
]
}),
tbar: new Ext.Toolbar({
items : [
'区域:',this.areaCombo,'-','厂家:',this.factoryCombo,'-',
{text : '同步网管',iconCls : 'find', handler :this.doQuery,scope : this}
]
})
});
this.initListener();
},
initListener: function(){
this.addListener("render", function() {
this.loadMask = new Ext.LoadMask(Ext.getBody(), {
msg : '正在载入数据,请稍候...'
});
this.store.load({params:{start:0,limit:5}});
}, this);
},
doQuery: function(){
// time = this.timeField.getValue();
// geoIds = this.areaCombo.getValue();
// methodIndex = this.methodCombo.getValue();
// typeStr = this.typeCombo.getValue();
//this.store.load({params:{start:0,limit:30, times:time, geoIds:geoIds,methodIndex:methodIndex,typeStr:typeStr}});
},
doExport: function(){
// var gId = geoIds+"";
// gId = gId.split("&").join("-");
// var tId = typeStr+"";
// tId = tId.split("&").join("-");
// window.location="exportPortFlow.action?stime="+time+"&geoIds="+gId+"&methodIndex="+methodIndex+"&typeStr="+tId;
},
rendererFlag:function(value, medadata, record, rowIndex, colIndex, store){
if(value==0){
return "<font color=gray>未同步</font>";
}
else if(value == 1) {
return "<font color=green>正在同步</font>";
} else if(value==2){
return "<font color=red>已同步</font>";
}else if (value==3){
return "<font color=blue>同步失败</font>";
}
},
rendererstate:function(value, medadata, record, rowIndex, colIndex, store){
if(value == 1) {
return "<font color=green>在用</font>";
} else if(value==2){
return "<font color=red>新增</font>";
}else if (value==3){
return "<font color=blue>删除</font>";
}
else{
return "<font color=gray>未知</font>";
}
}
});