1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    15
    Vote Rating
    0
    christophercheng is on a distinguished road

      0  

    Default Unanswered: pre-select checkboxes of gridpanel of "checkboxmodel" from store

    Unanswered: pre-select checkboxes of gridpanel of "checkboxmodel" from store


    I am trying to load data from store into a gridpanel with checkboxmodel, however, it produces an error "views is undefined". What's missing here?

    Code:
    Ext.define('MyGridPanel', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.myGridPanel',
        preventHeader: true,     
        store: Ext.create('StoreA',{
            autoLoad: false,
            listeners: {
                load: function() {
                }
            }
        }),
        columns: [
            { header: 'ID', dataIndex: 'id', hidden: true },
            { header: 'checked', dataIndex: 'checked', hidden: false },
            { header: 'Name',  dataIndex: 'passengerName', flex: 1 }
        ],
        selModel: new Ext.selection.CheckboxModel({
            mode: 'MULTI'
        }),
        selType: 'checkboxmodel',
        multiSelect: true,    
        loadForm: function(bookingHotelItemId) {
            var gridpanel = this;
            var store = this.store;
            this.store.load({
                method: 'get',
                url  : '/passenger!list.action',            
                callback: function(records, operation, success) {                 
                    Ext.each(records, function(item) {
                        var record = store.findRecord("id", item.data.id);
                        if (item.data.checked == "y") {
                            var record = this.getById(item.data.id);
                            gridpanel.getSelectionModel().select(record, false, false);
                        }
                    });
                },
                failure: function(form, action) {
                }
            });
        }
    });

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,580
    Answers
    540
    Vote Rating
    314
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    When does loadForm get called? Could you post the full stacktrace, including line numbers?

    A couple of things I notice.

    Firstly, you are putting a fully instantiated store into your define config. The store object will be put on the grid class's prototype. This means that all instances of your grid will share the same store.

    Secondly, you seem to be specifying your selection model options twice. I don't think it'll hurt but you might want to remove the duplication to avoid any confusion.

  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    15
    Vote Rating
    0
    christophercheng is on a distinguished road

      0  

    Default


    after a few trials and tests, I found out that I should "check" those checkboxes after render, because after the store is loaded, the form's view has not been created yet.
    By the way, if I do not create the store over there, what's the appropriate way of doing that? I thought about using StoreManager or 'define' it somewhere or even in the constructor

    Code:
    listeners: {
            itemdblclick: function(){
            },
            afterrender: function() {
                var selectedRecords = [];
                this.store.each(function(record) {
                    if (record.data.checked == "y") {
                        selectedRecords.push(record);
                    }
                });
                this.getSelectionModel().select(selectedRecords, false, false);
            }
        },

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,580
    Answers
    540
    Vote Rating
    314
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Using afterrender is a little risky. It makes 2 assumptions: the store is loaded before the grid renders and the store only loads once. I think using the refresh event might be a safer bet.

    I don't understand your question about the store.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi