Hey guys,
I've been searching the forums for hours (no exaggeration) and have gotten somewhere, but not quite my end goal.
To explain:
I have a grid which displays multiple 'inventory records' to the user. The idea is for the user to select multiple rows in the grid and export this data.
Now the data displayed in the grid is not the totality of the data that is needed to be exported, as such I have an SQL view that pulls the required data from the database and is filtered based on the date in the grid row. The grid is equipped with a toolbar action button that does an ajax callback called 'BulkExport' (see code below). This ajax call back action does not submit any data to the function.
From several posts I've put together with the following code, however it only ever exports the data related to the currently selected grid row.
Is it that the excel file is being overwritten each time the resultset is re-initialized? or is my code just plain wrong?
Help is much appreciated!
Thanks,
Laura-Kae
I've been searching the forums for hours (no exaggeration) and have gotten somewhere, but not quite my end goal.
To explain:
I have a grid which displays multiple 'inventory records' to the user. The idea is for the user to select multiple rows in the grid and export this data.
Now the data displayed in the grid is not the totality of the data that is needed to be exported, as such I have an SQL view that pulls the required data from the database and is filtered based on the date in the grid row. The grid is equipped with a toolbar action button that does an ajax callback called 'BulkExport' (see code below). This ajax call back action does not submit any data to the function.
From several posts I've put together with the following code, however it only ever exports the data related to the currently selected grid row.
Is it that the excel file is being overwritten each time the resultset is re-initialized? or is my code just plain wrong?
Code:
function BulkExport as C (e as P) dim js as C = "" dim i as N dim selectedCount as N dim cn as SQL::Connection dim rs as SQL::ResultSet dim args as SQL::Arguments dim batchSQL as C = "" 'Get count of checked rows selectedCount = e.checkboxRows.countChecked dim id[selectedCount] as N dim date[selectedCount] as D for i = 1 to selectedCount 'Get compound key from selected rows id[i] = eval("e.checkedRows.key"+i+ "[1]") date[i] = eval("e.checkedRows.key"+i+ "[2]") 'add date to sql args for select query args.add("InventoryDate"+i, date[i]) dim sql as c = "SELECT * FROM <ViewName> WHERE InventoryDate = :InventoryDate"+i+" " batchSQL = batchSQL + sql next i dim webpath as c = "<path to location where file is to be saved>" dim filename as c = "<excel filename>" dim fullname as c = webpath+filename if (cn.Open("::Name::<ConnectionName>")) then if (cn.execute(batchSQL, args)) then js = "window.location = '" dim flg as l = cn.ResultSet.NextRow() while flg rs = cn.ResultSet rs.ToExcel(fullname+".xlsx") js = js + "';" flg = cn.ResultSet.NextRow() end while else js = "alert('Failed, See error and try again. " + js_escape(cn.callResult.text) + "');" end if else js = "alert('Unable to connect to database. Please try again.');" end if BulkExport = js end function
Thanks,
Laura-Kae
Comment