求个EditorGridPanel和combobox一起使用的例子

yzf86211861 2010-11-11 10:02:16
如题最好带数据一起给我了,刚学EXT 太纠结了。我现在这样写,

var storeSupplement = new Ext.data.JsonStore
(
{
url:prj.root + 'form/SupplementCategories/ajax.aspx',
autoLoad:true,
root:"data",
fields:["SupplementID","SupplementName"],
listeners: {
beforeload: function(v) {
Ext.apply(this.baseParams,{
tag:'GetSupplementCategoriesList'
});
},
load : function() {
objSupplement.setValue(objSupplement.getValue());
}
}
}
);
storeSupplement.load();

var objSupplement = new Ext.form.ComboBox({

typeAhead: true,
forceSelection:true,
store: storeSupplement,
displayField: "SupplementName",
valueField: "SupplementID",
mode: "local",
allowBlank:false,
triggerAction: "all",
name: 'SupplementID',
width: 120
});


var gridColumns_ = new Ext.grid.ColumnModel([
_sm,
{ header: "<div align='center'>增补名称<div>", dataIndex: "SupplementName",editor: objSupplement,
width:50,align:'left'},
{ header: "<div align='center'>增补消耗<div>", dataIndex: "Supplement", width:50,align:'left'},
{ header: "<div align='center'>增补日期<div>", dataIndex: "SupplementDate",width:50, renderer: Ext.util.Format.dateRenderer('Y-m-d')},
{ header: "<div align='center'>船号<div>", dataIndex: "ShipID",width:50,hidden:true, align:'center'},
{ header: "<div align='center'>分段号<div>", dataIndex: "SessionID",width:50,hidden:true, align:'center'},
{ header: "<div align='center'>油漆类别<div>", dataIndex: "CategoriesID",width:50,hidden:true, align:'center'},
{ header: "<div align='center'>SupplementID<div>", dataIndex: "SupplementID",width:60,hidden:true, align:'left'},
{ header: "<div align='center'>ID<div>", dataIndex: "ID",width:60,hidden:true, align:'left'}
]);

在选combobox一个选项以后 居然显示的 是‘SupplementID’ 但是很明显是要显示 'SupplementName',
新人求救 最好给个这方面的 例子感激不尽。
...全文
270 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
yzf86211861 2010-11-15
  • 打赏
  • 举报
回复
没人解决就散发吧 纠结中
asdujiayong 2010-11-12
  • 打赏
  • 举报
回复
初使化前要确定你的combo已经把值load下来了
否则当然看不见了
yzf86211861 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 zoujp_xyz 的回复:]
引用 9 楼 yzf86211861 的回复:

引用 8 楼 zoujp_xyz 的回复:
JScript code

修改一下这一列(在combox的数据源中要显示的值)
{ header: "<div align='center'>增补名称<div>", dataIndex: "SupplementName",editor: objSupplement,width:50,alig……
[/Quote]
就是加了 这个你提供的代码后 这列 变成空白了,需要点击进去 才能看到数据,点击编辑的时候这列数据显示出来,是正确的 数据。加载的时候这列是空白,不知道怎么回事
zoujp_xyz 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 yzf86211861 的回复:]

引用 8 楼 zoujp_xyz 的回复:
JScript code

修改一下这一列(在combox的数据源中要显示的值)
{ header: "<div align='center'>增补名称<div>", dataIndex: "SupplementName",editor: objSupplement,width:50,align:'left',renderer:function……
[/Quote]
初始化列表又是另一回事了,只要你后台把grid的值传过来了。而且combox也有数据,就可以渲染了
yzf86211861 2010-11-12
  • 打赏
  • 举报
回复
在线等成功 马上结贴
yzf86211861 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 asdujiayong 的回复:]
也就是显是的是key,而不是value吧
给一个方法:

JScript code

Ext.ns("Ext.ux.renderer");

Ext.ux.renderer.ComboRenderer = function(options) {
var value = options.value;
var combo = options.combo;
if (!va……
[/Quote]
这样是能有值了 但是在初始化这个列表的时候这列看不到数据 是空白,只有在编辑的时候才看到下拉框数据.
能再帮下忙吗
按你的方法和8楼方法 效果一样初始化的 时候这列空白了
yzf86211861 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 zoujp_xyz 的回复:]
JScript code

修改一下这一列(在combox的数据源中要显示的值)
{ header: "<div align='center'>增补名称<div>", dataIndex: "SupplementName",editor: objSupplement,width:50,align:'left',renderer:function(value, metadata, record……
[/Quote]
这样是能有值了 但是在初始化这个列表的时候这列看不到数据 是空白,只有在编辑的时候才看到下拉框数据.
能再帮下忙吗
yzf86211861 2010-11-12
  • 打赏
  • 举报
回复
继续顶, 学这东西2个东礼拜了,遇到问题就不会 解决了 纠结啊
yzf86211861 2010-11-11
  • 打赏
  • 举报
回复
有人帮忙吗
zoujp_xyz 2010-11-11
  • 打赏
  • 举报
回复

修改一下这一列(在combox的数据源中要显示的值)
{ header: "<div align='center'>增补名称<div>", dataIndex: "SupplementName",editor: objSupplement,width:50,align:'left',renderer:function(value, metadata, record, rowIndex, colIndex, store){
for(var i=0;i<storeSupplement.getCount();i++){
if(value===storeSupplement.getAt(i).get("SupplementID")){
return storeSupplement.getAt(i).get("SupplementName");
}
}
}}

asdujiayong 2010-11-11
  • 打赏
  • 举报
回复
也就是显是的是key,而不是value吧
给一个方法:

Ext.ns("Ext.ux.renderer");

Ext.ux.renderer.ComboRenderer = function(options) {
var value = options.value;
var combo = options.combo;
if (!value) return; // skip if no value defined
var valueField = combo.valueField;
var displayField = combo.displayField;
var returnValue = '';
// get returnValue from comboBox-store
var idx = combo.store.findBy(function(record) {
if (record.get(valueField) == value) {
returnValue = record.get(combo.displayField);
return true;
}
});
// if not found return preloaded value from grid-store
if(idx != -1) {
combo.setValue(value);
}
return returnValue;
};

Ext.ux.renderer.Combo = function(combo) {
return function(value, meta, record, rowIndex, colIndex, store) {
return Ext.ux.renderer.ComboRenderer({
value : value,
meta : meta,
record : record,
combo : combo, // this is retreived from the column
gridStore : store
});
};
}

将editor加一个渲染函数
editor: objSupplement-->objSupplement,renderer: Ext.ux.renderer.Combo(objSupplement)
yzf86211861 2010-11-11
  • 打赏
  • 举报
回复
唉 死水啊
yzf86211861 2010-11-11
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lveclipse 的回复:]
给你的combox加一个select事件监听,当combox选中某个选项时,给你得grid使用record.set('','');
[/Quote]
能说具体点吗 我刚学这个东西2个礼拜 属于新人级别的
lveclipse 2010-11-11
  • 打赏
  • 举报
回复
给你的combox加一个select事件监听,当combox选中某个选项时,给你得grid使用record.set('','');
yzf86211861 2010-11-11
  • 打赏
  • 举报
回复
自己顶 等大牛

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧