当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Extjs 几个方法的讨论

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 Extjs 几个方法的讨论


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-02-27   浏览: 346 ::
收藏到网摘: n/a

下面我讲一下在使用Extjs遇到的一个问题,希望各位朋友看到这篇随笔以后,能给我指教,这里我先谢过了! 相信大家在做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中的第一行数据,其实在其他的方法也存在类似的问题,不知道这是什么原因。望各位朋友指教。