Results 1 to 3 of 3

Thread: Extjs 6 grid bind store and load

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default Extjs 6 grid bind store and load

    Hi,

    I have defined a grid and a model for it.
    Now I want to load the store after the grid is rendered ... without luck.

    Code:
    items: [ {        xtype: 'grid',
            bind: {
                store: '{certificates}'
            },
            columns: [ {
                xtype : 'actioncolumn',
                width : 40,
                resizable : false,
                sortable : false,
                menuDisabled : true,
                items : [ {
                    iconCls : 'fa fa-trash-o icon-padding',
                    tooltip : 'Lschen',
                    padding : 10,
                    handler : 'onDeleteCertificateButtonClicked'
                } ]
            }, {
                text : 'Datum',
                dataIndex : 'date',
                flex: 1
            }, {
                text : 'Klasse',
                dataIndex : 'level',
                flex : 1
            }, {
                text : 'Erstellt',
                dataIndex : 'created',
                flex : 1
            } ],
            listeners: {
                afterrender : function() {
                    console.log('afterrender');
                    this.getStore().reload();
                },
                viewready : function() {
                    console.log('view');
                    this.getStore().load();
                }
            }
        } ]
    The logs are printed to the console but the store is not loading!!!
    The only solution is to mark the store with 'autoLoad: true'.

    I don't know when the store is bind and everything is ready to load.

  2. #2
    Sencha Premium Member
    Join Date
    Mar 2015
    Location
    Germany
    Posts
    294
    Answers
    30

    Default

    It is a big problem of bind - it happens with delay and you have no way to get know when the value was bound, so you should do the stuff with small delay:

    Code:
     afterrender : function() {
     Ext.Function.defer(function() {
                    console.log('afterrender');
                    this.getStore().load();
    				}, 100, this);
                },

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default

    Doing it this way solved my problem.

    Code:
        onRender : function() {        
            var viewModel = this.getViewModel();
            
            viewModel.set('studentId', this.getView().student.get('id'));
            viewModel.notify();
            viewModel.getStore('certificates').load();
            
        },

Similar Threads

  1. Replies: 3
    Last Post: 18 Jul 2017, 6:13 PM
  2. Replies: 1
    Last Post: 1 Dec 2015, 3:57 PM
  3. Replies: 1
    Last Post: 28 Jan 2014, 12:17 PM
  4. Wait for store to load and then bind to grid
    By hieu79vn in forum Ext: Q&A
    Replies: 9
    Last Post: 25 Apr 2013, 3:29 PM
  5. How to load a dynamic store which is bind to a ListView
    By rimbaudsolaris in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 31 May 2010, 7:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •