Is it possible to know the row number when the user clicks the row. This number can change from what is loaded because of sorting.
The reason is I need to show a popup next to a specific row and while my current code works fine until I resort.
Any thoughts?
Thanks, and have a great weekend. This is NOT a rush.
James
This code loads rows into the grid
-----------------------------------------
var iRow = (grdSearchResults.getRowsNum() + 1);
sFunction = “showRestaurantPopup(\’”+iRow+"\’,\’"+sRestaurant+"\’);";
sURL = “<a href=’#’ style=‘color:#58585a;font-family:Arial;font-weight:normal;font-size:10pt;text-decoration:none;’ onclick='selectRestaurant(”+iRow+");’ onmouseover=setTimeout(’"+sFunction+"’,1000)>"+sRestaurant+""
grdSearchResults.addRow(iRow,[sURL,sLeadTime,mMinimum,sEstimatedPrice,mDeliveryCharge,iRating]);
-----------------------------------------------
This code displays the popup (not that you need to care, but just in case)
function showRestaurantPopup(iRow,sRestaurant) {
var iTop = ((iRow -1) * 25);
//if this section is visable, do not show the popup
if (document.getElementById(‘ssrs_select_info’).style.display.length == 0)
{
return;
}
showDiv(‘ssrs_select_restaurant_details’);
// zero is passed in to avoid the popup from closing when it “leaves” the base div
if (iRow !== 0)
{
document.getElementById(‘ssrs_select_restaurant_details’).style.top = iTop;
setInnerText(‘ssrs_select_restaurant_details_title’,sRestaurant);
}
}
You can use “onRowSelect” event. Event hander has parameters:
id - id of the clicked row;
ind - index of the clicked cell.
grid.attachEvent(“onRowSelect”, function(id,ind){
var rowIndex=grid.getRowIndex(id);// getting row index by it’s id
});