2
votes

I’m attempting to check a box in a grid using the CheckBoxSelectionModel.
As the grid loads data from my store, how do I get the rowIndex of the row being loaded? I would like to test the value of a particular column dataIndex, and based on the value I would like to select the box at the beginning of the row. This code does not work, but this is what I’d like to do:

   columns:

            [
                    {dataIndex: 'de_sealed_doc', renderer: function(value,rowIndex,store,record){

                    console.log('rowIndex == '+rowIndex);

                    var sealedDocIndex = this.rowIndex;

                    //var gridModel = grid.getSelectionModel().select(2);

                    grid.getSelectionModel().select(sealedDocIndex);

                    //grid.getSelectionModel().selectAll();

                    console.log('sealedDocIndex --> '+sealedDocIndex);
                    //console.log('gridModel--> '+gridModel);
                    console.log('value--> '+value);



                    },

                    hidden: true},

                    {header: 'Document #', dataIndex: 'de_seqno', width: 100},
                    {header: 'Docket Text', dataIndex: 'docketText', renderer: this.customRenderer, width: 1000},
                    {header: 'Document(s)', dataIndex: 'docsDisplay', width: 500}

            ],

Could someone please assist me with this? If you need to see more of the code, so that it makes more sense, just let me know.

1
I am not sure if I fully understand your question, is the data that your trying to render as a checkbox not true or false?egerardus
No, but thanks for your response. I wanted to test the value of a dataIndex, in this case "de_sealed_doc," and if the value was not equal to 'y', I wanted to check the box of row on which the value resides. @Abdel's solution worked.T. Ujasiri

1 Answers

0
votes

You should be able to get it working with few modifications to your code. Here are the fixes you require:

  1. You need to have the correct renderer function. Here is an example that will help you get all the data you will need:

    renderer: function(value,meta,record,rowIndex,colIndex,store,view){ // code goes here }

  2. Ensure you call the select method of Selection model correctly. Here is an example:

    selModel.select(rowIndex,true); // The second param set true is MUST if you need multiselect!

So, Here is how your code should look like:

renderer: function(value,meta,record,rowIndex,colIndex,store,view){     

    if(record.get('de_sealed_doc') == true){  // put your correct condition
        grid.getSelectionModel().select(rowIndex,true);
    }
}