(Note: You will likely need to add some extra classes or data attributes to the HTML to uniquely identify rows.) The reason you need to set both global (PHP) and JS variables is to make them accessible to client (JS) and server (PHP) code. This additional pointer would identify the detail table that the user wants to edit. When the user clicks on a field, I would also set a global variable and JS variable. This variable would be used to identify the record id that is currently selected for editing.
When a user clicks on the master table to select a record to edit, I would set a global (PHP session) variable and also a JS variable (I will explain why and how to do this later). That said, I may have an idea on how to achieve this (based on my experience in native PHP, HTML/CSS/JS), but it may or may not apply to Scriptcase. I’m sure the product has advanced quite a bit from where I left off. $.post(’…/blank_session_var_repo/index.php’,) //associate a unique read token to the var_instance_id so that later we can retirve it from the serverįull disclosure, it has been many years since I last used Scriptcase. save var_instance_id = var_value on the server via ajax. $.data( document.body, var_name, var_instance_id ) save var_name = var_instance_id on the client via jquery Var_instance_id = guid() // guid is a js function to generate a unique ID for any var_name, accessing the var_instance_id on the client and query the server for the var_value. goal: 1) store var_name name and a unique instance ID on the client STORING A VAR NAMED PER INSTANCEĮcho “js_session_var_write(’$var_name’, ‘$var_value’) ” įunction js_session_var_write(var_name, var_value) I was thinking of perhaps storing the value in a form with a hidden input field, but if I am not seeing $_GET/$_POST variables in the $GLOBALS array, I’m not sure it this approach has merit. Parse_str(parse_url($_SERVER, PHP_URL_QUERY), $qstring) Īt this point I could move the switch statement from the menu and into the grid, which would set the proper values for the SQL WHERE.īut I need to persist a variable somewhere that is unique to the application instance and then retrieve that value when the grid is refreshed.
Here is the OnScriptInit code to do that: I can also determine which menu item was selected by parsing $_SERVER and looking for parameter ‘sc_item_menu’. I can now determine in OnScriptInit whether the event was triggered by the menu or by a grid refresh. Perhaps I am a little bit closer to my goal. It seems that Scriptcase may be passing parameters through $_SESSION - and managing rules of GET/POST/SESSION internally. When I analyzed changes to the $GLOBALS array, $_GET was blank and $_POST had limited parameters.
I do not know if there is a bug in Scriptcase. I believe that the concept that Giu and you proposed should work. If I set the input global variable to optional, no error message is displayed, but it still seems to pick up the last global input value from the other window (very odd). When the input global variable is reset, an error message is triggered about a missing global variable. That said, I am not having much success with this.
Your clarification helped me understand Giu’s concept. The variables need to persist so that the grid pulls the correct data when refreshed. What I need is a way to define variables that are not local ($myvar) which are limited in scope to a Scriptcase event inside an application (mygrid), not global (), which are accessible to all applications in the project, not application-specific (attributes?), since mygrid is reused 40 times, but rather menu tab (iframe) specific, so that when a report is invoked from the menu application, variables are saved and accessible only to that instance of the application (menu tab/iframe). I can duplicate the grid application 40 times, and alter the SQL and grid title, but that creates a maintenance headache should the report need to change. If I open the report for area1, then open the report for area2 and then return to area1, if I perform any action that regenerates the grid, the WHERE clause picks up the last value of and, which in my example are actually the values for area2. This works without issue as long as I am viewing the most recent report that was opened. is used in the Grid Title and in the grid SQL - SELECT col1,col2,… In the menu application, I set the value of two global variables, and. Each report uses the same grid application(mygrid), with a different WHERE clause in the SQL to select the appropriate data. I have a project that uses a menu application as a front end to about 40 reports.