标签: extjs-stores

如何在ExtJS组合框中添加空项?

我想添加和清空项目(显示值为空,项目高度保持正常)到Ext.form.ComboBox.我在下面提到了2个链接来配置我的组合框,但它仍然没有显示空项目:

这是我的代码:

this.abcCombo = new Ext.form.ComboBox({
    name : 'abcCombo',
    hiddenName : 'abcCombo-id',
    fieldLabel : "My Combobox",
    width : 250,
    editable : false,
    forceSelection : true,
    mode : 'local',
    triggerAction : 'all',
    valueField : 'id',
    displayField : 'fullName',
    store : new Ext.data.JsonStore({
        fields : ['id', 'fullName']
    }),
    tpl : '<tpl for="."><div class="x-combo-list-item">{fullName}&nbsp;</div></tpl>'
});
Run Code Online (Sandbox Code Playgroud)

组合框存储的数据将在Ajax请求(即数据项中的3个项)之后加载.组合框只有3项(不是我预期的4项).你对我的问题有任何想法吗?!非常感谢!

combobox extjs extjs4 extjs3 extjs-stores

17
推荐指数
2
解决办法
3万
查看次数

什么是AngularJS等同于Backbone的集合?

在Angular JS中是否有相当于Backbone的CollectionExt JS的商店?我正在学习$ resource,但并没有完全掌握这方面的内容.

调节器

// This is the "collection" I'm interested in.
$scope.foos = [];

// Foo is a $resource.
Foo.query(function (foos) {

  // This works, but is there a smarter "collection" object?
  $scope.foos = foos;
});

$scope.createFoo = function (data) {
  var foo = new Foo(data);

  foo.$save(function (shinyNewFoo) {
    $scope.foos.unshift(shinyNewFoo);
  });
};
Run Code Online (Sandbox Code Playgroud)

说明

$scope.createFoo我制作一个新的Foo,坚持它,然后将它添加到我的穷人的集合,一个阵列.这工作正常,视图正确更新,但我太懒了.理想情况下,我想要一个我可以添加和删除的"集合"将自动POST/DELETE.也许类似以下内容.

假装实施

$scope.fooCollection = new CoolCollection({
  // specify the type of resources this collection will …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs backbone.js-collections extjs-stores angular-resource

10
推荐指数
1
解决办法
3540
查看次数

extjs - 应用程序启动时不应加载具有自动加载功能的存储

我有一个链接到商店的网格autoLoad: true.问题是商店在应用程序启动时加载,即使稍后在通过菜单访问时创建视图也是如此.

我在Application.js和视图中引用了商店,但我没有明确地对商店和视图进行实例化.

我不知道如何实现只在视图需要时才加载存储.

  • 如果我设置autoLoad: true,商店将在应用程序启动时加载.
  • 如果我设置autoLoad: false,商店根本没有加载.

我知道这是非常基本的,但我到目前为止都陷入困境.


以下是所有相关的参考代码:
app/store/Owners.js

Ext.define('Mb.store.Owners', {
    extend: 'Ext.data.Store',
    model: 'Mb.model.Owner',
    autoLoad: true,
    proxy: {
        ...
});
Run Code Online (Sandbox Code Playgroud)

的application.js

Ext.define('Mb.Application', {
    name: 'Mb',
    extend: 'Ext.app.Application',
    models: [
        'Owner'
    ],
    stores: [
        'Owners'
    ],
    ...
Run Code Online (Sandbox Code Playgroud)

应用程序/视图/ Owners.js

Ext.define('Mb.view.winbiz.Owners', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.test-gridPanel',
    store: 'winbiz.Owners',
    columns: [{
    ...
Run Code Online (Sandbox Code Playgroud)

视图在控制器中实例化:

Ext.define('Mb.controller.Winbiz', {
    extend: 'Ext.app.Controller',
    views: [
        'Owners'
    ],
    init: function(){
        this.control({
            'menu #test': {click: this.onMenuTest},
        })
    },
    onMenuTest: function(){
        this.getController('Main').addToMainTab('test-gridPanel');
    },
Run Code Online (Sandbox Code Playgroud)

extjs extjs4 extjs-stores extjs4.2

8
推荐指数
1
解决办法
3万
查看次数

使用filterBy()应用过滤器时从ExtJs存储清除过滤器的最快方法

我正在使用ExtJS 4.1.我正在使用商店clearFilter()从商店中删除过滤器.我正在使用filterBy方法将过滤器应用于商店.我正在过滤所有名字不是罗纳尔多的记录.

清除过滤器后,我加载一个包含网格的视图(附加到商店).但是当我加载网格时,我仍然可以看到过滤器未被清除.这家商店是当地商店.我没有在商店上应用任何分组.商店只使用一种型号.

myStore.filterBy(function (record) {
    if (record.get('Name') != 'Ronaldo') {
        return true;
    }
});
Run Code Online (Sandbox Code Playgroud)

虽然这一切都很好,但是当我通过使用清除过滤器时clearFilter(),需要一些时间.使用过滤器时,是否有更快\更好\正确的方法来清除商店中的过滤器filterBy()

javascript extjs extjs4.1 extjs-stores

8
推荐指数
1
解决办法
1万
查看次数

根据ExtJs 4.1网格中的另一列对一列进行排序

我正在使用ExtJs 4.1框架.我有一个网格,只显示一列(名称).网格与具有两个字段(Name和SortOrder)的商店相关联.商店中的"名称"字段与网格的"名称"列相关联.我想根据商店中SortOrder字段中可用的值对名称列进行排序.我怎样才能实现这样的逻辑.

谢谢

extjs4.1 extjs-stores extjs-grid

7
推荐指数
2
解决办法
4656
查看次数

如何等待所有商店在ExtJs中同步?

我有一个网格列表,可以由最终用户在表单中更改其数据.最后,我想通过单击按钮同步所有网格,然后执行操作.

我写了下面的代码:

$.when.apply(
    Ext.ComponentQuery.query('grid')
       .forEach(function(item) {
             if (item.getXType() == "grid") {
                if (item.store.getNewRecords().length > 0 || item.store.getUpdatedRecords().length > 0 || item.store.getRemovedRecords().length > 0) {
                    item.store.sync();
                 }
             }
})).then(function (results) {
    //do something
});
Run Code Online (Sandbox Code Playgroud)

问题在于store.sync()不等待回调.

这样做的推荐方法是什么?

javascript extjs promise gridpanel extjs-stores

6
推荐指数
1
解决办法
1万
查看次数

如何在ExtJS中的商店加载函数中使用作用域

this.loadSmt = function(argPanel) 
{
    this.store1 = new Ext.data.JsonStore({
        url             : 'URL1',
        totalProperty   : 'total',
        successProperty : 'success',
        root            : 'root1',
        fields          : [
                            {name: 'data1'},
                            {name: 'data2'}
                        ]
    });

    this.store2 = new Ext.data.JsonStore({
        url             : 'URL2',
        totalProperty   : 'total',
        successProperty : 'success',
        root            : 'root2',
        fields          : [
                            {name: 'data21'},
                            {name: 'data22'},
                            {name: 'data23'},
                            {name: 'data24'},
                            {name: 'data25'}
                        ]
    });

    this.store1.on('beforeload', function() {
        this.store1.baseParams = {
            argID: myID
        };
    }, this);

    this.store2.load({
        callback    : function() {
            var graphOwner = argPanel; …
Run Code Online (Sandbox Code Playgroud)

scope extjs extjs-stores

6
推荐指数
1
解决办法
5357
查看次数

Ext.data.Store的each()忽略了过滤后的记录

我正在使用Ext.data.Store的each().但是,当过滤存储时,此方法仅循环遍历过滤的记录.即使在商店中应用过滤器,我们是否有任何其他方法或解决方法来遍历商店的所有记录.

  var attStore = Ext.getStore("myStore");
        var allRecords = attStore.snapshot || attStore.data;
        allRecords.each(function (record) {
            if (record.data.IsUpdated) {
                record.set('updatedByUser', true);
            }
            else {
                record.set('updatedByUser', false);
            }
             record.commit();
        });
Run Code Online (Sandbox Code Playgroud)

该行 var allRecords = attStore.snapshot || attStore.data;实际上按预期返回所有记录,但是当我尝试使用record.data.property = something更新该记录(或该记录中的一个属性)时,该记录没有得到更新.

谢谢

extjs extjs4.1 extjs-stores

5
推荐指数
2
解决办法
2万
查看次数

如何在没有多次重载的情况下重用EXT JS 4 MVC应用程序中的存储?

我正在研究extjs 4 MVC应用程序.

应用程序运行Viewport,其中包含tabpanel.每个选项卡都有自己的控制器和多个视图

请访问http://wap7.ru/folio/ext-reuseable-store/TE.html查看我的沙盒

我有一个商店多次使用(例如topmenu组合框中的一个选项卡,clietns网格中的另一个选项卡.)配置了autoload的商店:true.代理在模型中配置.

我的问题:Store多次加载 - 在控制器[stores]数组中提到.

如果我从数组中删除一个[stores] controller- combobox将为空,尽管它表示store:Ext.getStore('STORE-ID')

请给我一个提示,或者重新使用商店(不是模型)的例子,如http://docs.sencha.com/ext-js/4-0/#!/guide/mvc_pt2

extjs reusability extjs4 extjs-mvc extjs-stores

5
推荐指数
1
解决办法
5912
查看次数

30秒后取消存储负载

我对商店负载有问题.Extjs在30秒后取消加载.是否有一些参数或其他东西来增加存储加载时间?

这是商店的例子:

  var store = Ext.create('Ext.data.Store', {
        model : 'store_model',
        proxy : {
            type : 'ajax',
            url : 'data/backend.php',              
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            }

        },          
        autoLoad : true
    });
Run Code Online (Sandbox Code Playgroud)

extjs store extjs4 extjs-stores

2
推荐指数
1
解决办法
9698
查看次数