Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Gaizka on Feb 11, 2009 23:02
open dhtmlx forum
Grid Context

I have two jsp pages, one for the search and another one for the data. So I've a dhtmlxGrid in the first one.
I select a row and navigate to the data page to show all of data of the row.

Then I push the "back" button and I want the grid loaded, ordered by the same column, in the same pagination page and with the same selected row.

I need to now the selected row, the page selected and the sorted column, to save them in the session. And, when return to the search page, reload again the grid, ordered by the column, the page and the row selected . Is it possible?

I've been searching for this and I got this:

var state = mygrid.getStateOfView();
var pageselected = state[0];
var rowselected = mygrid.getSelectedRowId();

With this I can select a row:
mygrid.setSelectedRow(id);

żbut the page and the order column?

Thanks.
Answer posted by dhxSupport on Feb 12, 2009 01:40

When you select row "onRowSelect" event fired. This event contain information about selected rowId and selected column index.

mygrid.attachEvent("onRowSelect", function(rowId,cellIndex){

//your code here

});

The current page is the "currentPage" grid property:

var cPage = grid.currentPage;

 changePage(pageNum) method can be used to change current page:

grid.loadXML(url,function(){
  grid.changePage(2);
});
grid.currentPage; and grid.changePage() method availible at PRO version only.

Answer posted on Feb 12, 2009 01:44
and the order column?
Answer posted by dhxSupport on Feb 12, 2009 02:02
You can save column order to cookies with method  mygrid.saveOrderToCookie();. To load column order from cookies use mygrid.loadOrderFromCookie();. You can see example here http://dhtmlx.com/docs/products/dhtmlxGrid/samples/rows_columns_manipulations/pro_column_states_save.html