有时候我们希望通过Store加载过来的数据,ComboBoxItem能够选择第一条数据作为默认数据,我们可以这么操作:

   var storeinfo = Ext.create('Ext.data.Store', {
model: SaleInfo,
autoLoad: false,
pageSize: , proxy: {
type: 'ajax',
url: '/URL/JSON',
reader: {
type: 'json',
rootProperty: 'Data',
totalProperty: 'TotalCount'
}
}
});

然后定义Storeinfo的Load方法,配置Callback回调

    ////数据加载之后,回调设置ComboBox选择第一项
storeinfo.load({
scope: this,
callback: function (records, operation, success) {
if (records.length > ) {
Ext.getCmp("BranchId").select(storeinfo.getAt());
}
else {
Ext.getCmp("BranchId").setRawValue("暂无独立法人");
}
}
});

即可;

备注:

1、setRawValue()设置comboBox显示文本内容,getRawValue()获取显示内容文本;

2、setValue()设置comboBox值,getValue()获取comboBox值;

Extjs ComboBox 动态选中第一项的更多相关文章

  1. Easyui combobox如何默认选中第一项???

    以下代码可以实现combobox默认选中第一项,在实际开发中我们可能会用到! // 处理combobox默认选中的问题 <input id="user_type" class ...

  2. 【WPF】ListBox使用DataTemplate 以及默认选中第一项Item

    ListBox中DataTemplate的用法如下 . <ListBox x:Name="areaLB" ItemsSource="{Binding AreaNum ...

  3. ionic中ng-options与默认选中第一项的问题

    1. select中动态添加数据时发现一个选项为空,在选中了其他选项时,在点击时发现第一个空选项消失了,所有我们需要设置一个默认的选项: 2. 开始的时候我用的方法: <select class ...

  4. easyui的combobox默认选中第一个选项

    pmProjectSelect.combobox({ editable:false, width:165, url : ctx + '/PmProject/findByProjectMgr', //c ...

  5. Easyui combobox下拉框默认选中第一项

    var val = $(#cc).combobox("getData");for (var item in val[0]) {       if (item == "gr ...

  6. jquery easyui combobox设置默认选中第一项

    combobox的内容是从后台获取的json, js截取: var data = $('#id').combobox('getData'); $("#id ").combobox( ...

  7. extjs Combobox动态加载数据问题,mode:local 还是remote

    var fabircTypeDs = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'province.do' }), reade ...

  8. EasyUI combobox动态增加选择项

    有需求需要动态的为combobox增加可选项,后来解决方案如下 html如下 <select id="workerList"></select> js 如下 ...

  9. 42.extjs Combobox动态加载数据问题,mode:local 还是remote

    问题: Java代码   var fabircTypeDs = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'province. ...

随机推荐

  1. apscheduler 绿色版

    由于依赖EntryPoint,因此apscheduler在离线的方式(直接拷贝然后引用)使用时,会报错. 错误信息类似: No trigger by the name “interval/cron/d ...

  2. List转换DataTable

    /// <summary> /// 将泛类型集合List类转换成DataTable /// </summary> /// <param name="list&q ...

  3. java实现远程储存读取文件

    import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileN ...

  4. openstacksdk enable logging

    http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/doc/source/users/guides/logging.rst

  5. 【IDEA】IDEA 如何设置编辑器字体大小

    intellij idea 如何更改编辑器文本字体和大小   换上了intellij idea之后,第一件事就是想要改变下文字字体,因为在我这个27寸的2k分辨率的屏幕上,文字显然太小了. intel ...

  6. CSS——display和float

    1.display 属性规定元素应该生成的框的类型. 值 描述 none 此元素不会被显示. block 此元素将显示为块级元素,此元素前后会带有换行符. inline 默认.此元素会被显示为内联元素 ...

  7. Binary Tree Non-recursive Traversal

    Preorder: public static void BSTPreorderTraverse(Node node) { if (node == null) { return; } Stack< ...

  8. Nodejs 及 NPM 的安装

    Nodejs 及 NPM 的安装,有两种方式: 方式1.Nodejs 及 NPM  一起安装 https://nodejs.org/en/download/  下载  Windows Installe ...

  9. Ebase Xi The world's best RAD platform.

    Ebase Xi : http://www.ebasetech.com/ The world's best RAD platform. Xi combines browser and mobile a ...

  10. android studio Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

    android studio Error:java.lang.OutOfMemoryError: GC overhead limit exceeded 在app下的build.gradle中找到and ...