㈠ EXTjs怎么给combox赋值
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(vari=0,max=obj.data.items.length;i<max;i++){
varter=obj.data.items[i];
InitData.Terminal.terminalNos.push({id:ter.id,name:ter.name});
}
}
});
}
//数据源
vart_store=Ext.create('Ext.data.Store',{
fields:['id','name'],
data:InitData.Terminal.terminalNos,
proxy:{
type:'memory',
reader:{
type:'json',
root:'items'
}
}
});
vartercombo=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=newList<Hashtable>();
HashtablertnVal=newHashtable();
List<string>terlist=Common.TerminalNo.TERMINAL_LIST;
if(terlist!=null)
{
for(inti=0;i<terlist.Count();i++)
{
Hashtableht=newHashtable();
ht["id"]=terlist[i];
ht["name"]=terlist[i];
list.Add(ht);
}
}
rtnVal["totalcount"]=terlist.Count();
rtnVal["items"]=list;
returnCreateJsonResult(true,data:rtnVal);
㈡ javascript中,checkbox的赋值
我根据xxq8210写的改出来的:
<body>
<form name="myform" method="post">
<div id="divF">
<input type="checkbox" name="checkboc" value="2" onclick="showAndCount('checkboc')">2<br />
<input type="checkbox" name="checkboc" value="3" onclick="showAndCount('checkboc')">3<br />
<input type="checkbox" name="checkboc" value="4" onclick="showAndCount('checkboc')">4<br />
<input type="checkbox" name="checkboc" value="2.5" onclick="showAndCount('checkboc')">2.5<br />
<input type="checkbox" name="checkboc" value="1.3" onclick="showAndCount('checkboc')">1.3<br />
<span>总数:<b id="bCount"></b></span></div>
</form>
<script>
//每次点击checkbox控件就会触发这个方法
function showAndCount(idx){
var chkVal=0;
var Val=0;
var sum=0;
var chks=eval("document.myform."+idx);//这一句的到所有name值为idx的checkbox控件。
//document.myform中的myform是你的form的name的值
for ( var i = 0; i < chks.length; i++){
chkVal= chks[i].checked ? 1 : 0;//选中值为1
Val=parseFloat(chks[i].value);//将对应checkbox的value值转成float型,因为有小数。
sum+=parseFloat(chkVal*Val);//累加和
}
document.getElementById("bCount").innerHTML = sum;
}
</script>
</body>
㈢ EXTJS 为下拉框赋值问题
EXTJS 下拉框 combobox 可以通过3种方式赋值
1定义时 用value:值
2.点击选项赋值
3.用setValue 或者 setRawValue 方法赋值
需要内注意的是容 setValue 或者 setRawValue 需要在对象 渲染后才能执行 否则或赋值失败
对于您的问题 要看代码 是否是在渲染后赋值 , 或者 在没有 setValue 时 是否正常
㈣ extjs中的ComboBox怎么动态赋值
xtype : 'combo',
emptyText : '请选择年份^',//下拉框初始显示字段
fieldLabel : '年份选择',
store : new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'info/infoMovie!getAllInfo.do'//提交到某action的某方法
}),
reader : new Ext.data.JsonReader( {}, [ 'movieYear' ]),//需要显示的数据实体字段
autoLoad : true
}),
displayField : 'movieYear', //显示文本字段
hiddenName : 'infoMovie.movieYear',//真正提交此combo时的name
valueField : 'movieYear', //值字段
triggerAction : 'all', //设置为”all”,否则默认 为”query”的情况下,
//你选择某个值后,再此下拉时,只出现匹配选项,
//如果设为”all”的话,每次下拉均显示全部选项
editable : false,
allowBlank : false
}
㈤ extjs grid 中 如何根据数据动态给checkbox赋值
renderer:function(v){
㈥ Extjs 4.x 得到form CheckBox 复选框的值
CheckBox(复选框)主要用来接收用户选择的选项
如图所示(请忽略UI的不好看):
该弹出窗口的主要代码如下:
复制代码
代码如下:
var
win
=
new
Ext.Window({
modal
:
true,
title
:
'确定要拒绝该表吗?',
width
:
500,
plain
:
true,
items
:
[fp]
});
win.show();
弹出的窗口是载体,items里面的[fp]是form表单的句柄。
具体定义如下:
复制代码
代码如下:
var
fp
=
Ext.create('Ext.FormPanel',
{
frame:
true,
fieldDefaults:
{
labelWidth:
110
},
width:
500,
bodyPadding:
10,
items:
[
{
xtype:
'fieldset',
flex:
1,
//title:
'确定要拒绝该张表吗?',
defaultType:
'checkbox',
layout:
'anchor',
defaults:
{
anchor:
'100%',
hideEmptyLabel:
false
},
items:[{
fieldLabel:
'请选择拒绝原因:',
boxLabel:
'该表没有填写完整。',
name:'integrity',
inputValue:
'1'
},
{
name:'correct',
boxLabel:
'该表填写不准确。',
inputValue:
'1'
}]
}],
buttons:
[
{text:
'确认',handler:
function(){
//得到完整性和准确性信息
有则为1
没有为0
if(fp.getForm().isValid()){
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
}
win.hide();
}
},{
text:
'取消',
handler:
function(){
win.hide();
}
}]
});
这里面基本涵盖了所有的感兴趣的信息。具体的参见API吧本身不难
着重说下得到checkBox的值
复制代码
代码如下:
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
这两句话就是如何得到完整性和正确性的值。
㈦ Extjs怎样获取checkBox的值
{
2xtype:'fieldset',
3title:'兴趣',
4autoHeight:true,
5defaultType:'checkbox',
6hideLabels:true,
7id:'xq',
8layout:'hbox',
9defaults:{
10flex:1
11},
12//vertical:false,
13items:[
14{boxLabel:'游泳',name:'xqn',inputValue:'4',checked:true},
15{boxLabel:'玩儿',name:'xqn',inputValue:'5'},
16{boxLabel:'游戏',name:'xqn',inputValue:'6'}
17]
页面效果: