PDA

View Full Version : grid onload not retaining selection



Pankaj Kumar M
29 Mar 2016, 2:46 AM
I'm need to select 3 rows (i.e. row num: 2, 5,7) in the grid in one page .

i) Here in the below code i'm able to select only the 7th row, other 2 rows are not getting selected.
ii) 7th row is getting selecting only when navigating to next page. Initially when the grid loads it is not selecting.




grid.store.on("load", function(){

grid = ColdFusion.Grid.getGridObject("grid");
var model = grid.getSelectionModel();
model.selectRow(2);
model.selectRow(5);
model.selectRow(7);
});

jdkhamba
29 Mar 2016, 6:10 PM
Looks like you are posting in the wrong forum
There is no selectRow function in selectionModel of a grid in ExtJS 4.x

This is probably what you are looking for:

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.selection.Model-method-select

If you are using extJS 3.x use selectRows with keepexisting as true :

http://extjs.cachefly.net/ext-3.2.1/docs/source/RowSelectionModel.html#method-Ext.grid.RowSelectionModel-selectRows

Pankaj Kumar M
30 Mar 2016, 7:21 AM
The code is below, i'm calling this function pagingFn on ajaxOnLoad on of cfgrid.

The code you posted is in bold. It is not firing.





pagingFn=function()
{
Ext.QuickTips.init();
grid = ColdFusion.Grid.getGridObject("gridname");


var data = grid.getStore();
var model = grid.getSelectionModel();


grid.reconfigure(grid.getStore(),cm);

//overwrite existing grid footer with new div, Ext.id() will assign unique id to footer
var bbar = Ext.DomHelper.overwrite(grid.bbar,{tag:'div',id:Ext.id()},true);
//Create new PaginToolbar and render it to bbar (grid footer)
gbbar = new Ext.PagingToolbar({renderTo:bbar,
store: grid.store,
pageSize: 10,
displayInfo: true,
displayMsg: '<b>Showing {0} - {1} out of {2} Transactions</b>',
emptyMsg: "<b>No Record</b>",
moveNext : function(){

grid = ColdFusion.Grid.getGridObject("gridName");
var sm = grid.getSelectionModel();
sm.select(selections, true,false);

},
items:[
'-', {
pressed: false,
enableToggle:false,
tooltip:'Click here',
text: 'View All',// The text that will show for the button in the bar
icon:'css/add.png',//Icon graphic
cls: 'x-btn-text-icon',//The ext class that will display the button with text/icon properly
handler:showGridAll// handler:showGridAll // should be replaced with your own function
}
]
});


}

jdkhamba
30 Mar 2016, 7:23 AM
What is the "grid" object? Is it an ExtJS grid? If not then obviously it won't fire :)