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

Question

Question

setFieldValues for table cell

asked on December 10, 2024

Hello,

In classic form, value for a given cell in a table can be assigned like $('[name="Field114(2)"]').val("-1").  How can this be done in the modern form designer using LFForm.setFieldValues?

Tks.

0 0

Answer

SELECTED ANSWER
replied on December 10, 2024

If you are assigning a specific value to each row you can use: 

LFForm.setFieldValues({fieldId: 52}, ["1", "2", "3", "4", "5", "6", "7"]); 

Just change out the values you are using.  

You can also use the Index 

LFForm.setFieldValues({fieldId: 51, index: 3}, "3");

Adjust the index value for the row you are assigning a value to.  The row will start at 0.

0 0

Replies

replied on December 10, 2024

This should help you with what you are looking for: Javascript in the Forms Designer

  • For a table or collection with 3 rows, where each row has a single line with field ID 10:
    • LFForm.setFieldValues({fieldId: 10}, "a"); // will set single line in every row to "a".
    • LFForm.setFieldValues({fieldId: 10, index: 0}, "hello"); // will set single line in first row to "hello".
    • LFForm.setFieldValues({fieldId: 10}, ["1", "2", "3"]); // will set single line in first row to "1", second row to "2" and third row to "3".
0 0
replied on December 10, 2024

Hello,

To clarify, I have a table with Fixed number of rows.  How do I reference to each row, say Binding, for I don't see the fieldID's in the Layout.  FieldID:52, I think, is referenced to the column?

 

 

 

0 0
SELECTED ANSWER
replied on December 10, 2024

If you are assigning a specific value to each row you can use: 

LFForm.setFieldValues({fieldId: 52}, ["1", "2", "3", "4", "5", "6", "7"]); 

Just change out the values you are using.  

You can also use the Index 

LFForm.setFieldValues({fieldId: 51, index: 3}, "3");

Adjust the index value for the row you are assigning a value to.  The row will start at 0.

0 0
replied on December 10, 2024

Here's my codes:

LFForm.onFieldChange(function(){
  if (LFForm.getFieldValues({fieldId:32}) == 1)
  {  
    console.log('Colored Print');
    console.log(LFForm.getFieldValues({fieldID:52,index:0}));
    LFForm.setFieldValues({fieldID:52,index:0},"0.3000");
  }  
  else
    console.log('Grayscale Print');
}, {fieldId: 32});

replied on December 10, 2024

Also, seems like the array is empty, not sure why.  There are 7 rows.

 

replied on December 10, 2024

There's a typo on my end.  Should be {fieldId... not {fieldID  

Many thanks for your help.

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

Sign in to reply to this post.