I've got a grid component with a checkbox column, and an action button in the grid toolbar above that calls the XBasic function below. This code was borrowed and modified, but has worked fine in multiple variations in multiple components, including this one.
This component is opened in a detail view of another component, and works inconsistently there. Sometimes it works, and sometimes it has an error of "...e.checkedRows subelement not found."
In working preview, it appears that e.checkedRows doesn't exist when no checkboxes are checked. But note in the code that to get to that line, it has passed the if statements requiring that there is at least one row checked, so e exists and theoretically has data in it. Can anyone help me understand why this sometimes fails?
Thanks in advance.
This component is opened in a detail view of another component, and works inconsistently there. Sometimes it works, and sometimes it has an error of "...e.checkedRows subelement not found."
In working preview, it appears that e.checkedRows doesn't exist when no checkboxes are checked. But note in the code that to get to that line, it has passed the if statements requiring that there is at least one row checked, so e exists and theoretically has data in it. Can anyone help me understand why this sometimes fails?
Thanks in advance.
Code:
IF eval_valid("e.checkboxRows.countChecked") = .t. IF val(e.checkboxRows.countChecked) > 0 dim AllKeyValues as c dim NumChecked as n dim conn as SQL::Connection dim sql_update as C conn.PortableSQLEnabled = .t. NumChecked = val(e.checkboxRows.countChecked)' Total Number of checked rows Key_Field = "PA_ID" 'Your key (id) field 'Get all keys FOR i=1 TO NumChecked KeyValue = eval("e.checkedRows.key" + i + "[1]") AllKeyValues = AllKeyValues + " OR "+Key_Field+ "=" + KeyValue next AllKeyValues = substr(AllKeyValues,4) SQL_Connection = "::Name::myservername" Table_Name = "[perf alerts]" Set_Values = "PA_IncludeOnMD = 0" 'Fields you want to change and its values divided by comas sql_update = "UPDATE "+Table_Name+" SET "+Set_Values+" WHERE "+AllKeyValues conn.open(SQL_Connection) 'Connection conn.execute(sql_update) Fn_Update = "{grid.object}.refresh();A5.msgBox.hide();alert('Selected Records will not show up on the current Monthly Documentation PDF.');" ELSE Fn_Update = "A5.msgBox.hide();alert('No Performance Alerts are currently checked.');" END IF END IF
Comment