jeudi 26 juillet 2018

Checking rows in extjs grid based on their state

I'm currently working on a project that uses ExtJS.

For this part of the project I had to implement a checkbox column on an existing grid, each row of the grid can have a state determined by record.data.codiceStato.

Here is part of the code :

 selectionModel = Ext.create('Ext.selection.CheckboxModel', 
               {  checkOnly : true, 
            listeners:{
                select:function(sm, idx, rec ){alert("Look ma!")}

             }      
                ,renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
                    if(record.data.codiceStato == 'RS' || record.data.codiceStato == 'AN' || record.data.codiceStato == 'NP')
                        return '<div style="margin-left: -1px;" class="' + Ext.baseCSSPrefix + 'grid-row-checker"> </div>'; 
                    else 
                        return ''; 
                }
           });

Now, as you can see, I only render the checkbox on certain rows that have a precise state(RS, AN, NP). My problem is that when I click on the header checkbox ALL the rows in the grid get selected, also those ones that are not in the state that should be able to be selected(state different than NP RS AN). Is there any way to fix this? Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire