Quantcast
Viewing all articles
Browse latest Browse all 21760

How can I select the row after a cfgrid refresh?

I have a form that is bound to a cfgrid.  The grid is populated from a database.  When you navigate in the grid the data displayed in the form changes to match the selected row.  I can edit the data in the form and update the database.  After updating the data I refresh the cfgrid, which then displays the updated data.

 

Unfortunately the cfgrid always highlights the first row, row 0, after a refresh.  I want to highlight the same row that was highlighted when the data was edited and saved.  Can anyone advise as to how I can do that?

 

I have tried setting a listener when the grid is initiated that responds whenever the store is refreshed and triggers the function refreshSelection():

g.getStore().on('load', refreshSelection) ;

 

Before the form data is saved, the row number is stored in selectedRow[0].  When the grid is refreshed, refreshSelection is run:

function refreshSelection() {
   
if (0 >= selectedRecords.length)
             return;
    }
alert('Selected row is Row ' + selectedRecords[0] ) ;
g.getSelectionModel().selectRow(selectedRecords[0]) ;
selectedRecords[0] = 0 ;
}

 

The alert shows the correct row number each time, but highlighting the last row viewed works intermittently, and only if the alert line is active.  If I comment out the alert, this fails every time, with row 0 being highlighted.  selectedRecords[0] is reset to 0 after the attempt to select the row so that navigation through the grid, such as choosing "Next Page," will properly highlight the first row of the page rather than the last row number that was edited.

 

-Rick


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>