cancel
Showing results for 
Search instead for 
Did you mean: 

DYNAMIC SUBTOTAL TEXT

cartercjb
10 - ETL
10 - ETL

I am trying to remove the Total text portion from the subtotal row so that it only reads the row value - COTA (highlighted in yellow): 

cartercjb_0-1647278470219.png

Referencing this KB article, I was able successfully this with the manual text replacement, but I'd rather it be dynamic. 

 

 

 

widget.on('ready',function(e, args){
	$('widget[oid="' + args.widget.oid + '"]').find('span:contains(" Total")').text("COTA");
})

 

 

 

I tried the script below but it only pulls the first level of Credential value, not the correct subsequent values

 

 

widget.on('ready',function(w, args){
$('[id="' + args.widget.oid + '"]').find('span:contains(" Total")').text($("[class='p-dim-member'][fidx='0']:first").find("span").text());
})

 

 

cartercjb_0-1647282802080.png

The second subtotal row should read PT not COTA. Then PTA, SLP, etc. 

 

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

@cartercjb 

Please check this script:

 

widget.on('ready',function(e, args){
$('[id="' + args.widget.oid + '"]').find('span:contains(" Total")').each(function(index){
    
    $(this).text($(this).text().replace(' Total', ''));
    })
})

 

-Hari

View solution in original post

3 REPLIES 3

harikm007
13 - Data Warehouse
13 - Data Warehouse

@cartercjb 

Please check this script:

 

widget.on('ready',function(e, args){
$('[id="' + args.widget.oid + '"]').find('span:contains(" Total")').each(function(index){
    
    $(this).text($(this).text().replace(' Total', ''));
    })
})

 

-Hari

Thank you, @harikm007  Hari! That worked like a charm, as always. 

Are you able to share any online resources outlining the each(function()index properties so I can learn more? Thank you!

harikm007
13 - Data Warehouse
13 - Data Warehouse

@cartercjb ,

Here are few online resources that may help to learn more about 'each' function:

https://api.jquery.com/each/

https://www.javatpoint.com/jquery-each-method

-Hari