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

Question

Question

default cell values for specific rows

asked on June 15, 2020

For a table for billing rates, I want to default the line item descriptions for the first three lines, then allow free form after this. 

As shown here, I am able to add these values in as Auto Suggestions, but my internal customer wants to default these items.  Would this be a javascript customization or is there a way to do this within the existing framework?

I would like to default this as follows:

Thank you,

Jason

0 0

Answer

SELECTED ANSWER
replied on June 15, 2020 Show version history

Well default-but-editable is actually more complicated.

If you want default and read only, then you could just use a function/calculation.

=INDEX(["First","Second","Third"],ROW())

What this is doing is creating an array/collection of values, which is represented by the square brackets.

["First","Second","Third"]

Next, that is wrapped in the INDEX function, which uses the ROW() function to get the current row number and retrieve the corresponding value from the array.

The reason this should be set to read-only is that changes in the table will often cause the calculation to refresh meaning if you let users edit the values, it will probably just revert back to the default.

 

However, if you have more rows than values, you will get a calculation error, so if you need to be able to add editable rows, JavaScript may be the way to go.

In that case, I'd set the table to start with a minimum of three rows and give that column's field a custom CSS class of "defaultField" or something.

Then just loop through your collection of default values and use the index to retrieve the corresponding field:

$(document).ready(function(){
  $.each(['First','Second','Third'],function(index,value){
    $('.defaultField input').eq(index).val(value).change();
  });
});

This is a very concise version, but there's lots of other ways to do this.

3 0

Replies

replied on June 15, 2020

Do you want them to be default but editable, or values the users cannot change?

0 0
replied on June 15, 2020

Default but editable would be just fine by me, gives the tool more flexibility, though I am not against values that the users cannot change.

 

Thank you,

Jason

0 0
SELECTED ANSWER
replied on June 15, 2020 Show version history

Well default-but-editable is actually more complicated.

If you want default and read only, then you could just use a function/calculation.

=INDEX(["First","Second","Third"],ROW())

What this is doing is creating an array/collection of values, which is represented by the square brackets.

["First","Second","Third"]

Next, that is wrapped in the INDEX function, which uses the ROW() function to get the current row number and retrieve the corresponding value from the array.

The reason this should be set to read-only is that changes in the table will often cause the calculation to refresh meaning if you let users edit the values, it will probably just revert back to the default.

 

However, if you have more rows than values, you will get a calculation error, so if you need to be able to add editable rows, JavaScript may be the way to go.

In that case, I'd set the table to start with a minimum of three rows and give that column's field a custom CSS class of "defaultField" or something.

Then just loop through your collection of default values and use the index to retrieve the corresponding field:

$(document).ready(function(){
  $.each(['First','Second','Third'],function(index,value){
    $('.defaultField input').eq(index).val(value).change();
  });
});

This is a very concise version, but there's lots of other ways to do this.

3 0
replied on June 15, 2020

Got it, this works.  I will work on it in the morning and mark it as the answer when done.  Thanks!

0 0
replied on June 16, 2020

The Javascript option works perfectly!  Once I have an example, I can adapt it, but I am still working on my skills to write JS, so thank you for the example.  Thank you for your insights!

Jason

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

Sign in to reply to this post.