I have a function that looks exactly like this:
function exportSelectedToExcel(id)
{
var selectedRows = new Array();
//Retrieve selected items from the grid
selectedRows = grid.getGridParam('selarrrow');
//Always add the item in id, it doesn't matter if it's there twice.
selectedRows[selectedRows.length] = id;
//Build the url
var params = selectedRows.join("&id=");
var exportUrl = "/Export/SelectListExporters?id=" + params;
//Show the selection form
SelectionWindow.show(exportUrl, "#selectionForm", 400);
}
Everytime I run this function the array grows with at least one item (the one i add to the end of it). This must surely mean that I have another array somewhere else in the system with the same name, right?
Is there any way in google chrome or firefox to find out where that variable is?
EDIT: There is no such variable in the whole project, verified from within visual studio.
EDIT 2: This is what I’m calling: http://www.secondpersonplural.ca/jqgriddocs/_2eb0fb79d.htm
EDIT 3: I’ve changed the code to start with the following:
var retrievedRows = grid.getGridParam('selarrrow');
var selectedRows = retrievedRows.slice(0);
Now it works like intended.
First of all, your code can be simplified to:
Looking at this it becomes obvious that
grid.getGridParam()(whatever it is) is the cause of the problem. Debug this (possibly by printingselectedRows) and investigate it.selectedRowsis declared locally inside a function, so even if there is a global variables named the same, it will not affect your function.