kpcollier Posted January 26, 2022 Report Share Posted January 26, 2022 I'm trying to disable some fields when the user is attempting to Inline Edit a record on my tabular report. I want to keep these fields 'editable' in the wizard so that the user can submit new records with the Inline Add button. I had a script running off of the InlineEdit button onclick that would disable the fields. This worked, but only for the top record in the report and only the first time you click it. So, I've tried this, with no luck either: var elements = document.querySelectorAll("a[data-cb-name='InlineEdit']"); for(var i = 0, len = elements.length; i < len; i++) { elements[i].onclick = function () { setTimeout(function(){ document.querySelector('select[id*="InlineEditEmployee_"]').disabled = true; document.querySelector('select[id*="InlineEditEquipment_"]').disabled = true; document.querySelector('select[id*="InlineEditBrand_"]').disabled = true; document.querySelector('input[id*="InlineEditSerial_"]').disabled = true; document.querySelector('input[id*="InlineEditInspection_Date_"]').disabled = true; document.querySelector('select[id*="InlineEditFP_Inspector_"]').disabled = true; }, 3000); } } Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
Volomeister Posted April 7, 2022 Report Share Posted April 7, 2022 Hi there! I believe mutationobserver might be useful. Here is how this solution might look: let observer = new MutationObserver( mutationRecords => { if(document.querySelector('select[id*="InlineEditEmployee_"]')!==null) { document.querySelector('select[id*="InlineEditEmployee_"]').disabled = true; document.querySelector('select[id*="InlineEditEquipment_"]').disabled = true; document.querySelector('select[id*="InlineEditBrand_"]').disabled = true; document.querySelector('input[id*="InlineEditSerial_"]').disabled = true; document.querySelector('input[id*="InlineEditInspection_Date_"]').disabled = true; document.querySelector('select[id*="InlineEditFP_Inspector_"]').disabled = true; } }); observer.observe(document.querySelector('article'), {childList: true, subtree: true}); I tested it on my table with different fields and it worked fine. Let me know if you have any questions about this approach. kpcollier 1 Quote Link to comment Share on other sites More sharing options...
Magda Posted October 4, 2022 Report Share Posted October 4, 2022 Hello! I've tried this code (with the MutationObserver) but there are 2 issues: Update doesn't work anymore, I get an error on the disabled fields saying "Cannot update this record because there are related records in the database". I believe the fields value are not send to be saved. It doesn't work on mobile version. The field is changing it's appearance (like is disabled) but you still can change the selected value. Maybe there is another solution to this ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.