For any support or more customized script, contact us -  binextlevel@gmail.com

Pivot2 - Spread color from one column to entire row

Currently, in pivot, we can set colors to a column based on its value. In that case color will get applied to only that column. Below script will spread color from a column to entire row




widget.on('ready', function(se, ev) {
	
	panelName = 'Value 1' //Update your panel name from which color needs to spread to entire row
	
	 if (prism.activeWidget == null)
	   widgetelement = $('[widgetid="'+ se.oid + '"] pivot2 .pivot-scroller table tbody tr')
	 else
	   widgetelement = $('.pivot-scroller table tbody tr')
	   
	var colIndex = -1
	$(widgetelement).each(function(index, trElement){ 
		if(index == 0)
		{
			$(trElement).find('td .table-grid__content .table-grid__content__inner').each(function(tdIndex, tdElement){
				if ($(tdElement).text() == panelName){
					colIndex = tdIndex
				}
			})
		}
		else{
			if(colIndex >= 0){
				bgColor = $(trElement).find('.table-grid__cell--col-' + colIndex).css('backgroundColor')
				$(trElement).find('td').each(function(tdIndex, tdElement){
					 $(tdElement).css('backgroundColor', bgColor)
				})

				$(widgetelement).each(function(rowIndex, rowElement){
					if(rowIndex > 0 && index == rowIndex){
						$(rowElement).find('td').css('backgroundColor', bgColor)
					}
				})
			}
		}

	})
})





73 views0 comments

Recent Posts

See All