1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    45
    Vote Rating
    0
    maxkliver is on a distinguished road

      0  

    Default Getting value of gridpanel's cell

    Getting value of gridpanel's cell


    Hi guys.
    I have a gridpanel with some columns. Also i have CheckboxSelectionModel. And i want to get value of cell with name "id" of checked rows.

    Code:
    var sm = new Ext.grid.CheckboxSelectionModel({
            //header: '',
            //singleSelect : 'true',
            listeners: {
                selectionchange: function(sm) {
                //alert('coucou : ' + sm.getSelected().id);
                alert('coucou : ' + sm.selectRow(0));
    
                }
            }
    });
    Columns

    Code:
    var cm = new Ext.grid.ColumnModel({
            columns: [sm,{
                xtype: 'checkcolumn',
                header: '',
                dataIndex: 'indoor',
                width: 50
            },{
                header: 'id',
                dataIndex: 'kad_id',
                width: 70
            },{
                header: 'Участок',
                dataIndex: 'kad_name',
                width: 130,
                }]
        })
    How to do this??

  2. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    45
    Vote Rating
    0
    maxkliver is on a distinguished road

      0  

    Default


    Ok im dummy. To get a value of cell with name id needed
    Code:
    var sm = new Ext.grid.CheckboxSelectionModel({
    
          listeners: {
           selectionchange: function(sm) {
           alert('coucou : ' + sm.getSelected().get("id"));
          }
        }
    });

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    45
    Vote Rating
    0
    maxkliver is on a distinguished road

      0  

    Default


    But how to get multiple select?

    Code:
    for(h=0;h<sm.getSelections().length;h++){
                                        alert(sm.getSelections[h].get("kad_id"));
                                    }
    Not work.

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    And i want to get value of cell with name "id" of checked rows.


    Hi!

    you may use following for multiple selections.

    Code:
    var selectedRecords=yourGrid.getSelectionModel().getSelection(),
    nameCellValues=[];
    
    for(var i=0;i<selectedRecords.length;i++){
      nameCellValues.push(selectedRecords[i].get('kad_id'));
    }
    above, nameCellValues (which is an array) contains your selected row's id cell values.
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    45
    Vote Rating
    0
    maxkliver is on a distinguished road

      0  

    Default


    Strange but this code work.

    Code:
    var getS=csm.getSelections();
                                    for(var hh=1;hh<csm.getSelections().length;hh++){
    //do something
                                    }

Thread Participants: 1