append attribute to tr element using data from detail table field

Hi,

How to add an attribute to the tr element with the value taken from a certain field in the detail table?

Example:

Design mode:

                <tr id="Transactions" data-repeat="">
                    <td class="data Transaction Date">@T2@</td>
                    <td class="data Description">@D3@</td>
                    <td class="data LCY">@C7@</td>
                    <td class="data Total_Used_Amount">@L5@</td>
                    <td class="data Category_Name">@T6@</td>
                </tr>

required output (source view):

                <tr id="Transactions" data-repeat="" class="Travel">
                    <td class="data Transaction Date">17/12/2017</td>
                    <td class="data Description">Expedia</td>
                    <td class="data LCY">850.00</td>
                    <td class="data Total_Used_Amount">1270.00</td>
                    <td class="data Category_Name">Travel</td>
                </tr>

                <tr id="Transactions" data-repeat="" class="Food">
                    <td class="data Transaction Date">17/12/2017</td>
                    <td class="data Description">Carrefour</td>
                    <td class="data LCY">50.00</td>
                    <td class="data Total_Used_Amount">1320.00</td>
                    <td class="data Category_Name">Food</td>
                </tr>

I tried the following script but it uses the same value of Category_Name (first transaction) for all the transactions:

var f = record.tables.detail[0];
results.attr(‘class’,f.fields[‘Category_Name’]);

Thanks,

farid

Try this:

Selector:_#table tbody tr_
where #table is the CSS ID selector of the above dynamic table

Script:

l>

results.each(function(index){ 
	let categoryName = record.tables.detail[index].fields.Category_Name;
	this.addClass(categoryName); ??
});

Thank you Rod, it worked perfectly.

Any idea why if I add .ToLowerCase() to the result I get the following error:

this.addClass(categoryName.ToLowerCase());
Error: Cannot find function ToLowerCase in object lease

Thanks.

JavaScript is case sensitive. Use _.toLowerCase():_

results.each(function(index){
    let categoryName = record.tables.detail[index].fields.Category_Name.toLowerCase();
    this.addClass(categoryName); ??
});