1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    San Mateo, CA
    Posts
    46
    Vote Rating
    0
    Answers
    7
    neurodon is on a distinguished road

      0  

    Default Answered: Using SelectionModel in the GridPanel

    Answered: Using SelectionModel in the GridPanel


    Hello,

    I have a GridPanel that loads it's records from a store. My goal is to select a row that matches a field/value pair in the store on the on the initialization of the GridPanel.

    Here is the code that runs in the 'viewready' event of the grid panel:

    Code:
        viewready: function(me,opts) {
          var record = me.getStore().findRecord('objectid',this.objectid);
          me.getSelectionModel().select(record);
        }
    The issue I am having is that for some reason, getSelectionModel() is not binding to the store properly. If I output the result of me.getSelectionModel().getCount()... it displays '0' even though I have 11 records in the store.

    What do I need to do to make this work?

    Thanks in advance,

    B

  2. I figured out how to highlight the row... it was easier to do it with the GridView.

    Here is my code in the GridPanel:

    Code:
          viewConfig: {
            loadMask:false,
            getRowClass: function(record, rowIndex, rowParams, store){
                if(this.highlightObjectID!=undefined) {
                    return record.get("objectid")==this.highlightObjectID ? "object-selected" : "";
                }
                return "";
            }
        }
    The SelectionModel still does not work however.

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    San Mateo, CA
    Posts
    46
    Vote Rating
    0
    Answers
    7
    neurodon is on a distinguished road

      0  

    Default


    I figured out how to highlight the row... it was easier to do it with the GridView.

    Here is my code in the GridPanel:

    Code:
          viewConfig: {
            loadMask:false,
            getRowClass: function(record, rowIndex, rowParams, store){
                if(this.highlightObjectID!=undefined) {
                    return record.get("objectid")==this.highlightObjectID ? "object-selected" : "";
                }
                return "";
            }
        }
    The SelectionModel still does not work however.

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    San Mateo, CA
    Posts
    46
    Vote Rating
    0
    Answers
    7
    neurodon is on a distinguished road

      0  

    Default


    I figured out what the issue was on the getSelectionModel() problem. getCount() returns the number of selected rows, not the total number of rows.