⑴ 怎么把用Ext生成多选下拉框
使用:lovcombo 多选下拉框 ,EXTjs的扩展控件。
可网络搜索下载, LovCombo.js 和样式表LovCombo.css (css可能不需要 )
使用方法:使用 xtype:'lovcombo' 其他属性和combo一样的。
jsp引用
<link rel="stylesheet" type="text/css" href="../resources/css/Ext.ux.form.LovCombo.css" />
<script type="text/javascript" src='../jslib/Ext.ux.form.LovCombo.js'></script>
找不到网络HI联系,发给你。
⑵ extjs下拉列表选择框combobox,数据源重新加载后如何设置默认选中的项
我建议你在url 中增加部分参数,js存储选中ids,并传递默认选中的数据,后台根据 选中状况以及关键字排序,在代码中根据传递的选中值,进行属性修改.
⑶ extjs怎么做成下拉框,画红框的那里变成下拉框,下面有之前不是下拉框的部分代码,请跟为大神帮帮忙
改成用combobox组件就可以
⑷ extjs 下拉框多选
//配置时设置多选多true即可
Ext.create('Ext.form.ComboBox',{
multiSelect:true
});
⑸ 用extjs技术怎么在行中嵌入下拉列表框
首先grid的是new
Ext.grid.EditorGridPanel可编辑的列表。这里可以配置参数单击或双击编辑所在行,具体的见api。
然后是这里new
Ext.grid.ColumnModel([
需要嵌入下拉列表框的察迟列这样定义就哦了
{header
:
"合同状态",width
:
100,sortable
:
true,align
:
"center",dataIndex
:
"state"
,editor
:
new
Ext.form.ComboBox({//编辑的时候变成下拉框。
triggerAction
:
"坦段all",
width
:
120,
editable:
false,
store
:
["建立让没誉","执行","作废","完结"],
resizable
:
true,
mode
:
'local',
lazyRender
:
true
})
}
⑹ Extjs怎么实现下拉框多选
|1、扩展js类库,在项目中建立一个 js文件,命名为:xxx.js 其代码为
if('function'!==typeofRegExp.escape)
{
RegExp.escape=function(s)
{
if('string'!==typeofs)
{
returns;
}
returns.replace(/([.*+?^=!:${}()|[]/\])/g,'\$1');
};
}
Ext.ns('Ext.form');
Ext.form.MultiSelect=Ext.extend(Ext.form.ComboBox,
{
checkField:'checked',
multi:true,
separator:',',
initComponent:function()
{
if(!this.tpl)
{
this.tpl='<tplfor=".">'+'<divclass="x-combo-list-item">'
+'<imgsrc="'+Ext.BLANK_IMAGE_URL+'"'
+'class="ux-MultiSelect-iconux-MultiSelect-icon-'
+'{[values.'+this.checkField+'?"checked":"unchecked"'
+']}">'
+'{[values.'+this.displayField+']}'
+'</div>'
+'</tpl>';
}
Ext.form.MultiSelect.superclass.initComponent.apply(this,arguments);
this.on(
{
scope:this,
beforequery:this.onBeforeQuery,
blur:this.onRealBlur
});
this.onLoad=this.onLoad.createSequence(function()
{
if(this.el)
{
varv=this.el.dom.value;
this.el.dom.value='';
this.el.dom.value=v;
}
});
},
initEvents:function()
{
Ext.form.MultiSelect.superclass.initEvents.apply(this,arguments);
this.keyNav.tab=false;
},
beforeBlur:function()
{
},
postBlur:function()
{
},
clearValue:function()
{
this.value='';
this.setRawValue(this.value);
this.store.clearFilter();
this.store.each(function(r)
{
r.set(this.checkField,false);
},this);
if(this.hiddenField)
{
this.hiddenField.value='';
}
this.applyEmptyText();
},
getCheckedDisplay:function()
{
varre=newRegExp(this.separator,"g");
returnthis.getCheckedValue(this.displayField).replace(re,this.separator+'');
},
getCheckedValue:function(field)
{
field=field||this.valueField;
varc=[];
varsnapshot=this.store.snapshot||this.store.data;
snapshot.each(function(r)
{
if(r.get(this.checkField))
{
c.push(r.get(field));
}
},this);
returnc.join(this.separator);
},
onBeforeQuery:function(qe)
{
qe.query=qe.query.replace(newRegExp(RegExp.escape(this.getCheckedDisplay())+'['+this.separator+']*'),'');
},
onRealBlur:function()
{
this.list.hide();
varrv=this.getRawValue();
varrva=rv.split(newRegExp(RegExp.escape(this.separator)+'*'));
varva=[];
varsnapshot=this.store.snapshot||this.store.data;
Ext.each(rva,function(v)
{
snapshot.each(function(r)
{
if(v===r.get(this.displayField))
{
va.push(r.get(this.valueField));
}
},this);
},this);
this.setValue(va.join(this.separator));
this.store.clearFilter();
},
onSelect:function(record,index)
{
if(this.fireEvent('beforeselect',this,record,index)!==false)
{
record.set(this.checkField,!record.get(this.checkField));
if(this.store.isFiltered())
{
this.doQuery(this.allQuery);
}
if(this.multi)
{
if(record.get("key")=="---"&&record.get(this.checkField))
{
this.setValue("---");
}
else
{
this.setValue(this.getCheckedValue());
}
}
else
{
this.clearValue();
this.value=record.get(this.valueField);
this.setRawValue(record.get(this.displayField));
this.list.hide();
}
this.fireEvent('select',this,record,index);
}
},
setValue:function(v)
{
if(v)
{
v=''+v;
if(this.valueField)
{
this.store.clearFilter();
this.store.each(function(r)
{
varchecked=!(!v.match('(^|'+this.separator+')'
+RegExp.escape(r.get(this.valueField))
+'('+this.separator+'|$)'));
r.set(this.checkField,checked);
},this);
this.value=this.getCheckedValue();
this.setRawValue(this.getCheckedDisplay());
if(this.hiddenField)
{
this.hiddenField.value=this.value;
}
}
else
{
this.value=v;
this.setRawValue(v);
if(this.hiddenField)
{
this.hiddenField.value=v;
}
}
if(this.el)
{
this.el.removeClass(this.emptyClass);
}
}
else
{
this.clearValue();
}
},
selectAll:function()
{
this.store.each(function(record)
{
record.set(this.checkField,true);
},this);
this.doQuery(this.allQuery);
this.setValue(this.getCheckedValue());
},
deselectAll:function()
{
this.clearValue();
}
});
Ext.reg('multiSelect',Ext.form.MultiSelect);
2、在ext-all.css文件最后,加入css样式
.ux-MultiSelect-icon{width:16px;height:16px;float:left;background-position:-1px-1px!important;background-repeat:no-repeat!important;}
.ux-MultiSelect-icon-checked{background:transparenturl(../images/default/menu/checked.gif);}
.ux-MultiSelect-icon-unchecked{background:transparenturl(../images/default/menu/unchecked.gif);}
3、使用
varDepartUserStore=newExt.data.Store(
{
proxy:newExt.data.HttpProxy(
{
url:'/Web/Manage/DeskTop/JSON/ScheleManager/GetSimpleDepartUserInfo.aspx'
}),
//读取Json
reader:newExt.data.JsonReader(
{totalProperty:"totalCount",root:"root"},
[
{name:'UserId',type:'int'},
{name:'UserName',type:'string'}
])
});
varDepartUserCbox=newExt.form.MultiSelect(
{
fieldLabel:'姓名',
labelStyle:'width:80px',
width:150,
editable:false,
id:'DepartUserDS',
hiddenName:'DepartUserIdDS',
store:DepartUserStore,
emptyText:'--请选择--',
allowBlank:false,
blankText:'请选择',
mode:'remote',
displayField:'UserName',
valueField:'UserId',
triggerAction:'all',
selectOnFocus:true,
listWidth:200
});
DepartUserStore.on('load',function()
{
DepartUserCbox.selectAll();//全选
});
DepartUserStore.load();
⑺ extjs中下拉框选择一项另外一项下拉框显示默认值(选择下拉框中的A1,另一下拉框自动选择B1)
$('#fId').combobox({
valueField: 'id',
textField: 'name',
editable:false,
panelHeight:'auto',
url : ctx+'mole/list.do',
onSelect : function(rec){
$('#pid').combotree('clear');
var url = ctx+'menu/mole/'+rec.id+'.do';
$('#pId').combotree('reload', url);
},
onLoadSuccess : function (data){
},
onLoadError : function(data){
$.messager.alert('提示','加载数据失败!','info');
}
});
以上是esayui中的下拉框 级联的代码示例
$('#pid').combotree('clear');
var url = ctx+'menu/mole/'+rec.id+'.do';
$('#pId').combotree('reload', url);
在上级选中后 把下级选择框内容清楚 在重新根据上级的id去加载即可
⑻ extjs 多选下拉框
用lvcombo插件就行了(地址:://extjs.eu/phpmv2/phpmyvisites.php?url=http%3A//lovcombo.extjs.eu/lovcombo-1.0.zip&id=1&pagename=FILE:%20download/lovcombo/lovcombo-1.0.zip)
教程:
{
xtype : 'lovcombo',
name : 'roles',
fieldLabel : 'Roles',
store : lvComboStore,
valueField : 'name',
displayField : 'name',
mode : 'local',
editable : true,
triggerAction : 'all'
}
⑼ ExtJS grid表头如何增加下拉项
extjs自己提供复选框列
//checkbox列
varfilecheckbox=newExt.grid.CheckboxSelectionModel();
//GridPanel
varfileGrid=newExt.grid.GridPanel({
store:fileStore,
columns:[
newExt.grid.RowNumberer(),//显示列数
filecheckbox,//显示复选框列
{//其他显示列}]
//省略其他属性
});
这样你就可以而得到一个复选框,可以进行单选、全选了
如果你想自己定义的话,也可以
//定义filters
varfilters=newExt.ux.grid.GridFilters({
//
encode:encode,//jsonencodethefilterquery
local:local,//defaultstofalse(remotefiltering)
filters:[{
type:'numeric',
dataIndex:'id'
},{
type:'string',
dataIndex:'company',
disabled:true
},{
type:'numeric',
dataIndex:'price'
},{
type:'date',
dataIndex:'date'
},{
type:'list',
dataIndex:'size',
options:['small','medium','large','extralarge'],
phpMode:true
},{
type:'boolean',
dataIndex:'visible'
}]
});
//
//
//thefiltertypes(
varcreateColModel=function(finish,start){
varcolumns=[{
dataIndex:'id',
header:'Id',
//=true
//tousestore'sfield'stypeproperty(iftypepropertynot
//'auto'which
//GridFilterswillassumetobe'StringFilter'
filterable:true
//,filter:{type:'numeric'}
},{
dataIndex:'company',
header:'Company',
id:'company',
filter:{
type:'string'
//
//,disabled:true
}
},{
dataIndex:'price',
header:'Price',
filter:{
//type:'numeric'//
}
},{
dataIndex:'size',
header:'Size',
filter:{
type:'list',
options:['small','medium','large','extralarge']
//,phpMode:true
}
},{
dataIndex:'date',
header:'Date',
renderer:Ext.util.Format.dateRenderer('m/d/Y'),
filter:{
//type:'date'//
}
},{
dataIndex:'visible',
header:'Visible',
filter:{
//type:'boolean'//
}
}];
returnnewExt.grid.ColumnModel({
columns:columns.slice(start||0,finish),
defaults:{
sortable:true
}
});
};
然后
vargrid=newExt.grid.GridPanel({
colModel:createColModel(4),
plugins:[filters],
//这两个属性是重点,加上去就可以了
});
效果看图片。
建议你去下载官方的源代码,然后看其中的例子。
里面有一个就是如何自定义这个的
⑽ extjs中下拉框的内容实现有条件选择,对应的情况下可以选择一些对应的选项
参考代码如下:
{ header: '单位名称', dataIndex: 'unitname',
field:
{ xtype: 'combo',
editable: false,
emptyText: "请选择...",
valueField: "id",
displayField: "text",
mode: 'local',
store: storeddl
}
}
var storeddl = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: "../../Handler/SystemHandler/UnitHandler.ashx?Lx=ddl"
},
root: 'items',
forceSelection: true,
// lazyRender: true,
fields: ['id', 'text'],
listeners:
{
select: selectRow,
focus: eventFocus
}
});