Re: How to disable a grid field if callback conditions are true
Well, I have completely abandoned the disabling concept for various reasons and am now using the nifty feature to replace a new value with the old value if it should not be changed. I also pop up a Javascript alert message that explains why to the user. Things are working well now. If anyone else is trying to accomplish the same type of thing, my comments on the function might help:
Well, I have completely abandoned the disabling concept for various reasons and am now using the nifty feature to replace a new value with the old value if it should not be changed. I also pop up a Javascript alert message that explains why to the user. Things are working well now. If anyone else is trying to accomplish the same type of thing, my comments on the function might help:
Code:
'FUNCTION PURPOSE: Prevent changes to a value in a field that should not be changed. 'Since grid uses RowOnDemand for editing, we are not able to use the Enable property of the field. 'That's because when Edit pencil is clicked, focus might try to move to a disabled field and will give error. 'We also need to do some lookups in child tables to check whether edit should occur, and need to do this via Ajax Callback. 'EVENT USED: This function is called by the MouseOut event of the field we are checking, 'so that it will fire before a user can click the Submit button. 'Using OnFocus or OnBlur does not work because field does not lose focus when user moves to the Submit button. 'Using OnChange does not work, because the code might make a change, and user will end up in a never ending loop. 'FUNCTION OVERVIEW: When the mouse moves out of the PROD_CODE field via the MouseOut event, this function will: '1 - Check to see if the value in the PROD_CODE field has changed. If not, nothing will happen. 'The test is: If e._currentRowDataOld.PROD_CODE <> e._currentRowDataNew.PROD_CODE then do the following... '2 - If change found, Check to see if the old value in the PROD_CODE field should not be changed, because is a program default. 'Example: If e._currentRowDataOld.PROD_CODE = "Change Order" then 'If so, old value will be returned to field: e._set.PROD_CODE.value = e._currentRowDataOld.PROD_CODE '3 - If change found, will then lookup to see if the old value in PROD_CODE has been used 'in the TblAPVendorsMasterData table as a default Cost Type for an employee. 'If so, old value will be returned to field: e._set.PROD_CODE.value = e._currentRowDataOld.PROD_CODE '4 - If change found, AND If it has not been used as an employee default, 'then the function will lookup to see if that PROD_CODE has been used in the AP_PRODUCT_ID field of TblPRCurrentPayroll. 'If so, old value will be returned to field: e._set.PROD_CODE.value = e._currentRowDataOld.PROD_CODE 'For the lookups, the function will use a count query to lookup and count the number of matching records found in the child table. 'If the count of the records found is greater than 0 (zero), then matching records were found in the child table. 'If the count of the records found is equal to 0 (zero) (which is the default count supplied by Alpha), then no matching records were found.
Comment