㈠ 怎麼獲得Extjs表格選中的值
你看這樣行么
var sm = new Ext.grid.CheckboxSelectionModel(); //選擇模型,定義checkbox選擇框,可選項
在做一個按鈕
tbar:{
text:'修改',
tooltip:'修改菜單',
iconCls:'viewButton',
handler:modfiy,
disabled:false
},
在寫一個modfiy事件
這里的.getSelectionModel().hasSelection()就是獲取值了
function modfiy(){
if (grid.getSelectionModel().hasSelection()){
var records=grid.getSelectionModel().getSelections();
if(records.length == 1){
var id=records[0].data['id'];
top.ExtModalDialog.show(
"修改菜單",
"sys/menuhandle.servlet?action=modfiy&id="+id,
null,
refresh,
{width:500,height:400}
);
}else{
top.Ext.Msg.alert('提示','請選中一條修改!');
}
}else{
top.Ext.Msg.alert('提示','請選中要操作的記錄!');
}
};
表的ID是gride
我試了試可以
㈡ extjs 復選框價格累加
累加的時候,你需要做下判斷,就是你選中的這個checkbox必須四海勾選狀態才累加,否則則減去這個價格
if(checks[rowIndex].checked==true){
var tempzongjia=zongjia+price;
}else{
var tempzongjia=zongjia-price;
}
我覺得你這塊代碼出了問題,你可以再這塊用alert測試,或者firebug調試,都可以
㈢ extjs 根據fieldset的checkBox情況,來全選checkBoxGroup
<!doctypehtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Extjs4.2demo</title>
<linkrel="stylesheet"href="../resources/css/ext-all.css">
<scriptsrc="../bootstrap.js"></script>
<script>
.onReady(function(){
Ext.create('Ext.Panel',{
width:450,
items:[{
xtype:'checkboxgroup',
listeners:{
change:function(gp,nv,ov,eOpts){
//全選
if(nv.all&&!ov.all)
returngp.eachBox(function(box,idx){
box.setRawValue(true);
});
//反選
if(ov.all&&!nv.all)
returngp.eachBox(function(box,idx){
box.setRawValue(false);
});
}
},
width:'100%',
fieldLabel:'AutoLayout',
cls:'x-check-group-alt',
items:[
{boxLabel:'全選',name:'all'},
{boxLabel:'Item1',name:'cb-auto-1',checked:true},
{boxLabel:'Item2',name:'cb-auto-2'},
{boxLabel:'Item3',name:'cb-auto-3'},
{boxLabel:'Item4',name:'cb-auto-4'}
]
},{
xtype:'button',
text:'GetChecked',
handler:function(){
Ext.Msg.alert('選中數量',String(this.up('panel').items.items[0].getChecked().length));
}
}],
renderTo:Ext.getBody()
});
});
</script>
</head>
<body>
</body>
</html>
㈣ extjs4.2 怎麼根據name 獲取 checkboxgroup選中的值
varCheckboxGroup=form.getForm().findField('name');
for(vari=0;i<CheckboxGroup.items.length;i++)
{
if(CheckboxGroup.items.itemAt(i).checked)
{
alert(CheckboxGroup.items.itemAt(i).name);
}
}
㈤ extjs中checkcolumn怎麼默認勾選部分checkbox
查看它對應的dataIndex名、在grid的store載入值時傳個布爾值應該就行了
㈥ extjs 如何根據資料庫欄位讓CheckboxSelectionModel選中
store 為grid的store,數據載入完後判斷一下ID=3的數據在store中的位置,然後選中這一行
store.on('load',function(store, records){
var index = store.find('ID',3);
grid.getSelectionModel().selectRow(index);
});
㈦ extjs 如何單擊下讓GridPanel里某一行的復選框選中
var sm = new Ext.grid.CheckboxSelectionModel({
//singleSelect: true,
listeners:{
//選中
"rowselect": function (grid,rowIndex,e) {
//使用這種方法會在先點擊最後一組數據的時候報錯
//var row=grid.getSelections();
//var val=row[rowIndex].get("id");
var grid = Ext.getCmp("shopGrid");
var val = grid.getStore().getAt(rowIndex).get("id");
sendUsersId.push(val);//存放用戶id
//alert(sendUsersId.toString());
},
//取消選中
"rowdeselect": function (grid, rowIndex, e) {
var grid = Ext.getCmp("shopGrid");
var val=grid.getStore().getAt(rowIndex).get("id");
sendUsersId.remove(val);//移除用戶id
//alert(sendUsersId.toString());
}
}
});
㈧ extjs CheckboxGroup默認選中問題
Ext.onReady(function() {
var port = new Ext.Viewport({
layout: 'border',
items: [chkEditDomain],
cls: "inner-viewport",
listeners: {
render: function() {
// Ext.getCmp("itemsid0").setValue("211", true);
// Ext.getCmp("itemsid0").setValue("212", true);
// Ext.getCmp("itemsid0").setValue("213", true);
// Ext.getCmp("itemsid0").setValue("214", true);
}
}
});
});
var chkEditDomain = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: '測試',
name: 'chkEditDomain',
allowBlank: false,
id: 'itemsid0',
width: 200,
columns: 4,
items: [
{ boxLabel: 'IND', name: 'IND', id: '211', inputValue: '5', checked:true },
{ boxLabel: 'CE', name: 'CE', id: '212', inputValue: '6' ,checked:true},
{ boxLabel: 'SC', name: 'SC', id: '213', inputValue: '8' ,checked:true},
{ boxLabel: 'FA', name: 'FA', id: '214', inputValue: '7' ,checked:true}
]
});
這樣行嗎?