bchic869
1 Feb 2007, 3:13 PM
First off, I'd like to complement the quality of the libraries. Truly excellent work.
Ok, I'd like to persist the selected row and selected sort order in a cookie. If that cookie exists, reset the grid to saved state.
Preserving the selected row was easy enough. The following snippet works great for me:
var stateMgr = YAHOO.ext.state.Manager;
function handleRowClick(aThis, aIndex, aObj)
{
stateMgr.set("UserTableRow", aIndex);
}
grid.addListener("rowclick", handleRowClick);
if (stateMgr.get("UserTableRow"))
{
grid.fireEvent("rowclick", grid, stateMgr.get("UserTableRow"), YAHOO.ext.EventObject);
}
I'd also like to do the sort order in a similar way. While it calls the headerclick event (the alert fires) the order of the rows does not change:
function handleHeaderClick(aThis, aIndex, aObj)
{
alert("handling header click");
stateMgr.set("UserTableSortCol", aIndex);
}
grid.addListener("headerclick", handleHeaderClick);
if (stateMgr.get("UserTableSortDir"))
{
grid.fireEvent("headerclick", grid, stateMgr.get("UserTableSortCol"), YAHOO.ext.EventObject);
}
Any help would be appreciated. Thanks!
Ok, I'd like to persist the selected row and selected sort order in a cookie. If that cookie exists, reset the grid to saved state.
Preserving the selected row was easy enough. The following snippet works great for me:
var stateMgr = YAHOO.ext.state.Manager;
function handleRowClick(aThis, aIndex, aObj)
{
stateMgr.set("UserTableRow", aIndex);
}
grid.addListener("rowclick", handleRowClick);
if (stateMgr.get("UserTableRow"))
{
grid.fireEvent("rowclick", grid, stateMgr.get("UserTableRow"), YAHOO.ext.EventObject);
}
I'd also like to do the sort order in a similar way. While it calls the headerclick event (the alert fires) the order of the rows does not change:
function handleHeaderClick(aThis, aIndex, aObj)
{
alert("handling header click");
stateMgr.set("UserTableSortCol", aIndex);
}
grid.addListener("headerclick", handleHeaderClick);
if (stateMgr.get("UserTableSortDir"))
{
grid.fireEvent("headerclick", grid, stateMgr.get("UserTableSortCol"), YAHOO.ext.EventObject);
}
Any help would be appreciated. Thanks!