top of page

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', element)
	   
	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)
					}
				})
			}
		}

	})
})




250 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page