Sorry if this is too verbose or confusing...
I have a master grid (loan table) with a grid link to a detail grid (document table). They are linked on a Loan_ID field. Both grids are MS-SQL based.
I am attempting to provide a single search form that will filter the master grid on multiple fields in either or both tables (for example: show only loans that have documents with a status of X).
Now, since I'd like to make some of the search fields optional, arguments don't appear to be an option. If someone can share how to make arguments optional in a SQL statement, ignore the rest of this. Otherwise...
My attempt now is to create a third 'search' grid, use an Ajax callback to build a subquery based on the fields selected in the Search grid, and open the Loan grid using the subquery built in the Search grid.
I've created a third Search grid with the fields to search on. I've created a button on the grid, and using Action Javascript created a button that runs an ajax callback. The ajax callback successfully writes a SQL subquery based on the fields in the grid.
Next, I need to open the loan grid on a div in the page, with the SQL statement created by the callback. I've used Action Javascript in the dummy grid to open the loan grid in a div, and to overwrite the SQL statement in the loan grid. I then converted this to text mode. But I don't know how to pass the statement that is created by the callback into the override.
I've tried using the Ajax callback to set a javascript variable that contains the subquery, but it does not pull the variable into the SQL override for the Loan grid. This is where I'm stumped
Here's what I tried (stripped down considerably):
OnClick Declarations-Global tab:
Xbasic Function Declaration- Ajax Callback:
I have a master grid (loan table) with a grid link to a detail grid (document table). They are linked on a Loan_ID field. Both grids are MS-SQL based.
I am attempting to provide a single search form that will filter the master grid on multiple fields in either or both tables (for example: show only loans that have documents with a status of X).
Now, since I'd like to make some of the search fields optional, arguments don't appear to be an option. If someone can share how to make arguments optional in a SQL statement, ignore the rest of this. Otherwise...
My attempt now is to create a third 'search' grid, use an Ajax callback to build a subquery based on the fields selected in the Search grid, and open the Loan grid using the subquery built in the Search grid.
I've created a third Search grid with the fields to search on. I've created a button on the grid, and using Action Javascript created a button that runs an ajax callback. The ajax callback successfully writes a SQL subquery based on the fields in the grid.
Next, I need to open the loan grid on a div in the page, with the SQL statement created by the callback. I've used Action Javascript in the dummy grid to open the loan grid in a div, and to overwrite the SQL statement in the loan grid. I then converted this to text mode. But I don't know how to pass the statement that is created by the callback into the override.
I've tried using the Ajax callback to set a javascript variable that contains the subquery, but it does not pull the variable into the SQL override for the Loan grid. This is where I'm stumped
Here's what I tried (stripped down considerably):
OnClick Declarations-Global tab:
Code:
window['{grid.componentName}_G__UNBOUND_BUTTON_3_2'] = function(rowNum,rowId,objEle) { ... go.overrideSettings = 'CS.SQL = `SELECT ... FROM ... WHERE dbo_document_tracking.Loan_ID IN ' + sqlwherestmt + ' GROUP BY ...`||||Style_name = `{Grid.style}`'; go.a5_default_path = '{grid.defaultPath}';
Code:
function set_subquery as c (e as p) cWhereStmt = "(SELECT dbo_TRACKING_FILE.Loan_ID FROM ... WHERE" cWhereStmt = cWhereStmt + '...add the search field stuff cWhereStmt = cWhereStmt + ")" set_subquery = "var sqlwherestmt = '" + js_escape(cWhereStmt) + "';" end function
Comment