You are viewing limited content. For full access, please sign in.

Question

Question

Is there a way to make a dynamic table field read-only?

asked on August 11, 2015

Is there a way to make a field read-only from a table that is dynamic. In the sense that more rows can be added. I attempted treat this as if it was a normal text field by using javascript to make it read-only and this did not work. Would I have to have a loop to change the input box to read-only?

0 0

Answer

SELECTED ANSWER
replied on August 11, 2015

Give the field a CSS class like read-only. Then you can use JavaScript like

$(document).ready(function () {
  
  $('.read-only input').attr('readonly',true);
  
  $('.cf-table-add-row').click(function () {
    $('.read-only input').attr('readonly',true);
  });
  
});

The idea is that the initial fields with the read-only CSS class will be read only. Then, when you click the "Add" button to add more rows to the table, it will make any new fields with the read-only CSS class read only.

4 0
replied on August 23, 2017

Would this be the same Javascript if the Table is filled from a Lookup Rule? I can only get the first row to be read only.

 

Thanks

0 0
replied on December 15, 2017

I have the same question as @████████. How would you alter this to work if the table is being populated from a lookup rule?

0 0

Replies

replied on August 12, 2015

Hi there,

I'm interested to know what's your real world use case for dynamic table, and which part is read-only?

0 0
replied on August 12, 2015

The table is required to be dynamic to add extra entries to it. It is initially doing a calculation for the total per row. These totals per each row have been requested to be read-only so the user is not able to cause any errors or attempt to change the total that had been calculated. The reason for utilizing javascript or css to change the field to read-only is that there were issues before when storing the form to the repository and not saving the calculated totals. This can be used in such cases for expense reports, stock buying/selling calculations, or gas reimbursement. The reason for the calculation per row is that it was decided upon to be able to see each expense per row so auditors or approvers could identify each row total instead of having to calculate it themselves and not only have an overall total to look at.

0 0
replied on August 12, 2015

thanks! Can you share a screenshot of the table if possible?

0 0
replied on August 13, 2015

Here is a snippet of the area for what it looks like.

DynamicTable.PNG
DynamicTable.PNG (13.22 KB)
0 0
replied on August 13, 2015

thanks!

0 0
replied on March 22, 2016

I use this to verify that the lookup process on the field value that the user supplied returned a value from the database and populated the table row read-only field. Otherwise the user entered an invalid field value and the form should not be submitted.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.