1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    52
    Vote Rating
    0
    Ghurdyl is on a distinguished road

      0  

    Default pre-selection grid checkbox

    pre-selection grid checkbox


    Hello,

    I'm trying to pre-select some rows in a grid when it is rendered.
    This is a simple GridPanel with a JsonStore an a local array data source.

    No matter what I try, I can't pre-select rows.
    Actually, I can set rows as selected in the CheckboxSelectionModel but the view isn't updated.

    If I just trigger the view.refresh() method after a short while, then I see the right checked items.

    So it's as if there where a synchronization problem, or I don't use the right event.
    But until now, I'm stuck ...

    Any hint is welcome.
    Thanks.

  2. #2
    Sencha User conorarmstrong's Avatar
    Join Date
    Mar 2008
    Location
    Northern Ireland
    Posts
    224
    Vote Rating
    2
    conorarmstrong is on a distinguished road

      0  

    Default


    can we see some code? Are you using the RowSelectionModel methods to select???

    Can't help much till we see something
    ------------------------------------------
    Conor Armstrong
    tw: @evathedog
    web: rockstown.com

    Ext.ux.form.AutoCombo
    Ext.ux.SimpleIFrame
    Ext.ux.form.ToolFieldSet

    Knowledge is realising that the street is one-way, wisdom is looking both directions anyway.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    52
    Vote Rating
    0
    Ghurdyl is on a distinguished road

      0  

    Default


    Here's a piece of code showing the issue :
    Code:
    var MyGrid = Ext.extend(Ext.grid.GridPanel, {
        initComponent: function() {
            
            this.store = new Ext.data.JsonStore({
                autoDestroy: true,
                storId: 'testStoreId',
                fields: ['id', 'name']
            });
            
            this.selModel = new Ext.grid.CheckboxSelectionModel();
            
            this.colModel = new Ext.grid.ColumnModel({
                defaults: {
                    sortable: true
                },
                columns : [{
                    header: 'id',
                    dataIndex: 'id',
                    hidden: true
                }, {
                    header: 'Name',
                    dataIndex: 'name',
                    width: 100
                }, this.selModel]
            });
            
            this.viewConfig = {
                forceFit: true,
                scrollOffset: 18
            };
        
            this.buttons = [{
                text : 'Force Refresh',
                handler: this.btnRefresh_click,
                scope: this
            }];
                        
            this.store.on('load', function(store, record){
                // pre-select records
                this.getSelectionModel().selectRecords([store.getAt(1)], true);
                this.getSelectionModel().selectRecords([store.getAt(2)], true);
                this.getView().refresh();
            }, this);
            
            MyGrid.superclass.initComponent.call(this);
            
            this.on('afterrender', function(){
                this.store.loadData([{
                    id: '1',
                    name: 'item 1'
                }, {
                    id: '2',
                    name: 'item 2'                    
                }, {
                    id: '3',
                    name: 'item 3'                    
                }, {
                    id: '4',
                    name: 'item 4'                    
                }, {
                    id: '5',
                    name: 'item 5'                    
                }]);
            }, this);
    
        },
        
        btnRefresh_click: function(btn, evt) {
            this.getView().refresh();
        }
    });
    
    Ext.onReady(function(){
        new Ext.Window({
            title: 'testWindow',
            width: 350,
            height: 200,
            layout: 'fit',
            items: [{
                xtype: 'tabpanel',
                activeItem: 0,
                items: [new MyGrid({
                    title: 'MyGrid Panel',
                    layout: 'fit',
                    width: 'auto'
                })]
            }]
        }).show();
    });
    When the window opens, record 2 and 3 should be checked but no matter they are set as selected in the SelectionModel, they are not checked.
    If you click the button, it will just call refresh() on the view and the checked lines will turn on.
    I would like that those lines would automatically be checked without this "refresh" button I added.
    Last edited by Ghurdyl; 28 Mar 2011 at 3:26 AM. Reason: spelling

  4. #4
    Sencha User
    Join Date
    Jun 2010
    Posts
    52
    Vote Rating
    0
    Ghurdyl is on a distinguished road

      0  

    Default


    none has any idea ?

  5. #5
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750
    Vote Rating
    7
    fay will become famous soon enough fay will become famous soon enough

      0  

    Default


    I think you've got to put your logic into the grid's viewready event:

    Code:
     
    this.on('viewready', function(grid){
      this.getSelectionModel().selectRows([1,2], true);
    }

  6. #6
    Sencha User
    Join Date
    Jun 2010
    Posts
    52
    Vote Rating
    0
    Ghurdyl is on a distinguished road

      0  

    Default


    yay !
    Million thanks that works just fine !

Similar Threads

  1. How to use a checkbox in a grid? not for row selection
    By zhenyuandeng in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 29 Jan 2010, 11:29 PM
  2. Grid+CheckBox -- Not for selection
    By rvent in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 25 Jun 2008, 10:01 AM
  3. Checkbox Selection Grid help
    By Amberite in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 24 Jun 2008, 4:35 PM

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar