㈠ 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]
頁面效果: