View Full Version : retain selection in grid

Pankaj Kumar M
6 May 2016, 5:03 AM
I have to retain the selections for this grid if any rows are selected and navigating to other rid pages and come back to the same page.

<cfgrid format="html" name="gridWorkingBillsDetailsPaging" selectOnLoad="false"
textColor="##000080" colHeaderTextColor="##000080" colHeaderAlign="right"
colHeaderFont="verdana" colHeaders="yes" colHeaderBold="yes" width="1100"
colHeaderFontSize="12" align="center" autowidth="true" multirowselect="true" selectmode="row" pagesize="10"
{cfgridsortcolumn},{cfgridsortdirection})" >
<cfgridcolumn name="TRANS_ID" header="T Id" width="80" headerbold="true" />
<cfgridcolumn name="REF_ID" header="Ref Id" width="100" headerbold="true" />
<cfgridcolumn name="FIRST_NAME" header="First Name" width="80" headerbold="true" />
<cfgridcolumn name="LAST_NAME" header="Last Name" width="80" headerbold="true" />
<cfgridcolumn name="CONF_NUM" header="Conf Num." width="60" headerbold="true" />
<cfgridcolumn name="START_DATE" header="Start Date" width="60" headerbold="true" />
<cfgridcolumn name="END_DATE" header="End Date" width="60" headerbold="true" />
<cfgridcolumn name="PAY_AMOUNT" header="Amount" dataAlign="right" width="80" headerbold="true" />
<cfgridcolumn name="CURRENCY" header="Currency" width="50" headerbold="true" />
<cfgridcolumn name="STATUS" header="Status" width="50" headerbold="true" />
<cfgridcolumn name='action' header='Action' width="125" headerbold="true" /> </cfgrid>
<cfset ajaxOnLoad("fnPaging")>


function fnPaging ()
grid = ColdFusion.Grid.getGridObject("gridWorkingBillsDetailsPaging");

//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>", items:[
'-', {
pressed: false,
tooltip:'Click here to View All Transaction Details',
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 } ] });

grid.store.on("load", function(){
grid = ColdFusion.Grid.getGridObject("gridName");
var model = grid.getSelectionModel();
// variable row has the row numbers to be selected
model.selectRow(row); });

Gary Schlosberg
6 May 2016, 12:53 PM
Why are you creating the grid with ColdFusion and not Ext JS?

Pankaj Kumar M
9 May 2016, 12:27 AM
The requirement is to use grid with cold fusion (i.e. CFGRID).

I have to retain while navigating through grid pages.

9 May 2016, 3:27 AM
You can't be using ExtJS grid functions such as getSelectionModel() etc on a coldfusion grid because they don't exist. You will have to use ExtJS grid. Also, since there seems to be nothing else that is ExtJS specific, this question seems to be more suited for a Adobe Coldfusion forum rather than an ExtJS forum.

Gary Schlosberg
9 May 2016, 3:33 PM
Does ColdFusion not have paging for their grid?

Pankaj Kumar M
19 May 2016, 6:36 AM
Hi Gary,

Cold Fusion has paging. but to retain the selection while navigating i have to use EXT JS

Thank you

Gary Schlosberg
19 May 2016, 1:49 PM
I'd have to agree with jdkhamba's recommendation to use an Ext JS grid if you're looking to retain the selection while navigating.

Pankaj Kumar M
20 May 2016, 3:52 AM
Can i get a link or an example , how to to take the details from database and display in the grid using EXT JS

Gary Schlosberg
20 May 2016, 2:55 PM
Here's an example with paging.

You can see the JSON returned by the php script if you navigate to it in your browser.

You'll likely need to write some code to get the data from your database into a JSON object.