1.当设置combox从远程加载数据,并且指定了valueField和displayField时,要想在服务器端获取valueField的值,
则必须指定hiddenName,并且该字段的值应该和name字段一致,但是此时不能再指定id字段,否则将出现:下拉列表出现
的位置不是在combox的正下方,而是在其它位置显示下拉列表
2.使用EditorGridPanel时,如果其中一列可编辑列使用了combobox,在编辑了combobox后显示的通常不是combobox的displayField字段值,
而是valueField字段值,此时需要对该列进行渲染,例如:
var groupStore=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:path+'/protected/pmg!listAllGroup.action'
}),
reader:new Ext.data.JsonReader({
id:'groupId'
},[
{
name:'groupId'
},{
name:'groupName'
}
])
});
groupStore.load();
var groupEditor=new Ext.Editor(
new Ext.form.ComboBox({
id:'groupcom',
name:'groupcom',
displayField:'groupName',
valueField:'groupId',
store:groupStore,
mode:'remote',
editable:true,
width:120
}),{
listeners:{
'complete':function(e,newGroupId,oldGroupName){
var record=store.getAt(roleIdIndex);
var id=record.get('id');
var newGroupName=Ext.getCmp('groupcom').getRawValue();
if(oldGroupName==newGroupName)return;
modifyUserGroup(id,newGroupId,record,newGroupName);
}
}
}
);
var renderGroup=function(value,p,r){
var index=groupStore.find(Ext.getCmp("groupcom").valueField,value);
var record=groupStore.getAt(index);
if(record==null){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+value+"</span>";
}
else{
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+record.data.groupName+"</span>";
}
}
cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header:"<input type='checkbox' οnclick='selectAll(this)'/>", align:"center",width:30,id:"checkbox"
,renderer:function(value, cellmeta, record, rowIndex){
return '<input type="checkbox" name="cb">';
}},
{header: "ID", align: 'center',width: 25, sortable: true, dataIndex: 'id',hidden:true},
{header: "用户名", align: 'center', width: 80, sortable: true, dataIndex: 'username'
,renderer:function(value){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+value+"</span>";
}},
{header:"用户角色",align:'center',width:120,sortable:true,dataIndex:'role',editor:roleEditor,renderer:function(value){
if(value==0){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>普通用户</span>";
}else if(value==1){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>企业管理员</span>";
}else if(value==2){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>应用管理员</span>";
}else if(value==3){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>系统管理员</span>";
}
}},{
header:'所属组',align:'left',width:120,dataIndex:'groupName',editor:groupEditor,renderer:renderGroup
}
]);
3.在js中,如果要频繁的使用系统提供的某一个集成函数(方法)如:document.getElementById("")、Ext.getCmp('')、formPanel.getForm().findField('')当然这里的formPanel
必须提前定义好,那么我们可以用struts2中set标签类似的方法来解决这个问题,我们可以定义自己的方法:
$ = function (field){
return formPanel.getForm().findField(field);
}
$=function(id){
return document.getElementById(id);
}
则必须指定hiddenName,并且该字段的值应该和name字段一致,但是此时不能再指定id字段,否则将出现:下拉列表出现
的位置不是在combox的正下方,而是在其它位置显示下拉列表
2.使用EditorGridPanel时,如果其中一列可编辑列使用了combobox,在编辑了combobox后显示的通常不是combobox的displayField字段值,
而是valueField字段值,此时需要对该列进行渲染,例如:
var groupStore=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:path+'/protected/pmg!listAllGroup.action'
}),
reader:new Ext.data.JsonReader({
id:'groupId'
},[
{
name:'groupId'
},{
name:'groupName'
}
])
});
groupStore.load();
var groupEditor=new Ext.Editor(
new Ext.form.ComboBox({
id:'groupcom',
name:'groupcom',
displayField:'groupName',
valueField:'groupId',
store:groupStore,
mode:'remote',
editable:true,
width:120
}),{
listeners:{
'complete':function(e,newGroupId,oldGroupName){
var record=store.getAt(roleIdIndex);
var id=record.get('id');
var newGroupName=Ext.getCmp('groupcom').getRawValue();
if(oldGroupName==newGroupName)return;
modifyUserGroup(id,newGroupId,record,newGroupName);
}
}
}
);
var renderGroup=function(value,p,r){
var index=groupStore.find(Ext.getCmp("groupcom").valueField,value);
var record=groupStore.getAt(index);
if(record==null){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+value+"</span>";
}
else{
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+record.data.groupName+"</span>";
}
}
cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header:"<input type='checkbox' οnclick='selectAll(this)'/>", align:"center",width:30,id:"checkbox"
,renderer:function(value, cellmeta, record, rowIndex){
return '<input type="checkbox" name="cb">';
}},
{header: "ID", align: 'center',width: 25, sortable: true, dataIndex: 'id',hidden:true},
{header: "用户名", align: 'center', width: 80, sortable: true, dataIndex: 'username'
,renderer:function(value){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>"+value+"</span>";
}},
{header:"用户角色",align:'center',width:120,sortable:true,dataIndex:'role',editor:roleEditor,renderer:function(value){
if(value==0){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>普通用户</span>";
}else if(value==1){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>企业管理员</span>";
}else if(value==2){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>应用管理员</span>";
}else if(value==3){
return "<span style='color:#cc00ff;font-weight:bold;cursor:hand;' title='双击可编辑'>系统管理员</span>";
}
}},{
header:'所属组',align:'left',width:120,dataIndex:'groupName',editor:groupEditor,renderer:renderGroup
}
]);
3.在js中,如果要频繁的使用系统提供的某一个集成函数(方法)如:document.getElementById("")、Ext.getCmp('')、formPanel.getForm().findField('')当然这里的formPanel
必须提前定义好,那么我们可以用struts2中set标签类似的方法来解决这个问题,我们可以定义自己的方法:
$ = function (field){
return formPanel.getForm().findField(field);
}
$=function(id){
return document.getElementById(id);
}