EXTJS怎么给combox赋值
从后台获得数据然后在根据判断0则使combox显示运行,1显示停机!vartabForm=newExt.FormPanel({width:430,height:370,f...
从后台获得数据然后在根据判断 0 则使combox显示运行 ,1显示停机 !
var tabForm = new Ext.FormPanel({
width:430,
height:370,
frame:true,//圆角和浅蓝色背景
title:"4号楼1层 群体控制设定",
bodyStyle:"padding:5px 5px 0",
items:[
{
fieldLabel: "运行/停机",
id: "onoff",
xtype: "combo",
store: [[0:运行],[1:停机]]
},
function inStart() {
xmlHttp = createXMLHttpRequest();
// alert(parent.parent.parent.document.getElementById('inid').innerHTML);
// var inner_id = parent.parent.parent.document.getElementById('in_con_page').src;
var inner_id =parent.parent.parent.document.getElementById('inid').innerHTML;
if (inner_id.length >0) {
var url = 'http://' + window.location.host
+ '/wems-hitachi/InnerSVGServlet?sts=get&inid='
+ inner_id;
xmlHttp.open('GET', url, true);
xmlHttp.onreadystatechange = setInnerSvg;
xmlHttp.send(null);
}
}
function setInnerSvg() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200 || xmlHttp.status == 500) {
if (Isflag) {
var str = xmlHttp.responseText;
// var obj = JSON.parse(str);
var flag = true;
var obj;
try {
obj = eval('(' + str + ')');
} catch (e) {
flag = false;
}
if (flag) {
// 开关
if (obj.onoff == 0) {
Ext.getCmp('onoff').setValue(0);
} else if (obj.onoff == 1) {
Ext.getCmp('onoff').setValue(0);
}
}
}
Ext.getCmp('singlesvgWindow').show();
//if (parent.parent.parent.document.getElementById('mainflag').innerHTML == 'inner') {
//}
}
}
} 展开
var tabForm = new Ext.FormPanel({
width:430,
height:370,
frame:true,//圆角和浅蓝色背景
title:"4号楼1层 群体控制设定",
bodyStyle:"padding:5px 5px 0",
items:[
{
fieldLabel: "运行/停机",
id: "onoff",
xtype: "combo",
store: [[0:运行],[1:停机]]
},
function inStart() {
xmlHttp = createXMLHttpRequest();
// alert(parent.parent.parent.document.getElementById('inid').innerHTML);
// var inner_id = parent.parent.parent.document.getElementById('in_con_page').src;
var inner_id =parent.parent.parent.document.getElementById('inid').innerHTML;
if (inner_id.length >0) {
var url = 'http://' + window.location.host
+ '/wems-hitachi/InnerSVGServlet?sts=get&inid='
+ inner_id;
xmlHttp.open('GET', url, true);
xmlHttp.onreadystatechange = setInnerSvg;
xmlHttp.send(null);
}
}
function setInnerSvg() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200 || xmlHttp.status == 500) {
if (Isflag) {
var str = xmlHttp.responseText;
// var obj = JSON.parse(str);
var flag = true;
var obj;
try {
obj = eval('(' + str + ')');
} catch (e) {
flag = false;
}
if (flag) {
// 开关
if (obj.onoff == 0) {
Ext.getCmp('onoff').setValue(0);
} else if (obj.onoff == 1) {
Ext.getCmp('onoff').setValue(0);
}
}
}
Ext.getCmp('singlesvgWindow').show();
//if (parent.parent.parent.document.getElementById('mainflag').innerHTML == 'inner') {
//}
}
}
} 展开
2个回答
展开全部
if (typeof (InitData) == 'undefined' || InitData == null) { InitData = {}; }
InitData.Terminal = {
terminalNos: [{id:'', name:'全部'}] //下拉框终端号
}
// 从后台取值
InitData.init = function () {
// 初始数据的取得
Com.Ajax.createAjaxRequest({
url: 'Data/GetTerminalData',
succFn: function (obj) {
for (var i = 0, max = obj.data.items.length; i < max; i++) {
var ter = obj.data.items[i];
InitData.Terminal.terminalNos.push({ id: ter.id, name: ter.name });
}
}
});
}
// 数据源
var t_store = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
data: InitData.Terminal.terminalNos,
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
var tercombo = Ext.create('Ext.form.ComboBox', {// 条件:终端编号
fieldLabel: '终端编号',
id: id_combo_terminal,
name: 'slipInfo.Terminal',
labelWidth: 80,
width: 278,
value: '', // 设置默认选中值
store: t_store,
editable: false, // 设置为只可选择,不可编辑
queryMode: 'local', // 本地数据时使用'local'
//triggerAction: 'all',
valueField: 'id',
isplayField: 'name'
});
c# 后台
List<Hashtable> list = new List<Hashtable>();
Hashtable rtnVal = new Hashtable();
List<string> terlist = Common.TerminalNo.TERMINAL_LIST;
if(terlist != null)
{
for(int i=0; i<terlist.Count(); i++)
{
Hashtable ht = new Hashtable();
ht["id"] = terlist[i];
ht["name"] = terlist[i];
list.Add(ht);
}
}
rtnVal["totalcount"] = terlist.Count();
rtnVal["items"] = list;
return CreateJsonResult(true, data: rtnVal);
展开全部
var statusCombo = Ext.create('Ext.form.ComboBox', {
width : 120,
x : 200,
y : 0,
store : [['0', '运行'], ['1', '停机']],
queryMode : 'local',
editable : false,
allowBlank : false,
});
//给下拉框赋值 :[ jiXieStore 某数据源的加载事件触发时给下拉框赋值]
jiXieStore.on("load",function(){
//如果想将deptField的值默认选中,只需要setValue即可
deptField.setValue(0);
});
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询