Extjs 几个方法的讨论
作者:bea
相信大家在做Extjs开发的时候都使用过类似下面的代码: 代码如下: var form_pz = new Ext.form.FormPanel({ id: "form_pz", region: "center", labelAlign: "right", lazyRender: true, frame: true, items: [{ xtype: "combo", fieldLabel: "产品名称", id: "CPMC", al
相信大家在做Extjs开发的时候都使用过类似下面的代码:
代码如下:
var form_pz = new Ext.form.FormPanel({
id: "form_pz",
region: "center",
labelAlign: "right",
lazyRender: true,
frame: true,
items: [{
xtype: "combo",
fieldLabel: "产品名称",
id: "CPMC",
allowBlank: false,
store: new Ext.data.SimpleStore({//store的定义}),
displayField: "CPMC_BBH",
valueField: "ID",
anchor: "100%",
mode: "local",
triggerAction: "all",
readOnly: true,
typeAhead: true,
}]
});
var data = [];//里面定义任意数据
Ext.getCmp("Store_id").load(data);
此时对这个下拉框以下操作的时候,即让它默认选中Store中第一行数据:
代码如下:
var record= Ext.getCmp("CPMC").getStore().getAt(0);
var value = record.get("ID");
Ext.getCmp("CPMC").setValue(value);
以上是主要程序,这样运行以后,下拉框是不会自动选中的,
然而把Store单独拿出来定义:
代码如下:
var Strore_CPMC = new Ext.data.SimpleStore({//定义});
Strore_CPMC.load(data);
var record= Ext.getCmp("CPMC").getStore().getAt(0);
var value = record.get("ID");
Ext.getCmp("CPMC").setValue(value);
下拉框就会自动选择store中的第一行数据,其实在其他的方法也存在类似的问题,不知道这是什么原因。望各位朋友指教。
有用 | 无用
代码如下:
var form_pz = new Ext.form.FormPanel({
id: "form_pz",
region: "center",
labelAlign: "right",
lazyRender: true,
frame: true,
items: [{
xtype: "combo",
fieldLabel: "产品名称",
id: "CPMC",
allowBlank: false,
store: new Ext.data.SimpleStore({//store的定义}),
displayField: "CPMC_BBH",
valueField: "ID",
anchor: "100%",
mode: "local",
triggerAction: "all",
readOnly: true,
typeAhead: true,
}]
});
var data = [];//里面定义任意数据
Ext.getCmp("Store_id").load(data);
此时对这个下拉框以下操作的时候,即让它默认选中Store中第一行数据:
代码如下:
var record= Ext.getCmp("CPMC").getStore().getAt(0);
var value = record.get("ID");
Ext.getCmp("CPMC").setValue(value);
以上是主要程序,这样运行以后,下拉框是不会自动选中的,
然而把Store单独拿出来定义:
代码如下:
var Strore_CPMC = new Ext.data.SimpleStore({//定义});
Strore_CPMC.load(data);
var record= Ext.getCmp("CPMC").getStore().getAt(0);
var value = record.get("ID");
Ext.getCmp("CPMC").setValue(value);
下拉框就会自动选择store中的第一行数据,其实在其他的方法也存在类似的问题,不知道这是什么原因。望各位朋友指教。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 使用SyntaxHighlighter实现HTML高亮显示代码的方法
- JavaScript学习笔记(十七)js 优化
- javascript 实现的完全兼容鼠标滚轴缩放图片的代码
- jQuery生成asp.net服务器控件的代码
- js实现的仿Photoshop鼠标滚轮控制输入框取值(修正兼容Chrome)
- js中鼠标滚轮事件详解(firefox多浏览器)
- JavaScript面向对象之静态与非静态类
- JavaScript 学习笔记(十六) js事件
- js左侧多级菜单动态的解决方案
- javascript 三种编解码方式
- 对字符串进行HTML编码和解码的JavaScript函数
- javaScript 关闭浏览器 (不弹出提示框)
- javascript让setInteval里的函数参数中的this指向特定的对象
- 详细讲解JS节点知识
- javascript中的array数组使用技巧
- jquery 批量上传图片实现代码
- Jquery 常用方法经典总结
- javascript 匿名函数的理解(透彻版)
- JavaScript 学习笔记(十五)