Google Chart Table Remove Highlight

I am currently working with Google chart tables. I have a problem with the elections. I want to turn off selection, but that seems impossible. I even tried (a real ugly way) as an event listener on the select part, which uses the clearChart () method to remove this.

Here is the sourche test code. Please note that I cannot use this in jsfiddle

<script type="text/javascript" src="https://www.google.com/jsapi" ></script> <script type="text/javascript"> google.load("jquery", "1"); google.load('visualization', '1', {packages:['table']}); function drawVisualization() { var data = google.visualization.arrayToDataTable([ ['', 'Name', 'E-mail', 'Activated', 'Last login'], ['<input type="checkbox">', 'name1', ' name1@company.xxx ', true, '20-07-2012'], ['<input type="checkbox">', 'name2', ' name2@company.xxx ', true, '21-07-2012'] ]); var options = {}; options['showRowNumber'] = false; options['page'] = 'enable'; options['allowHtml'] = true; options['pageSize'] = 18; options['pagingButtonsConfiguration'] = 'auto'; var visualization = new google.visualization.Table(document.getElementById('table')); visualization.draw(data, options); } google.setOnLoadCallback(drawVisualization); </script> <div id="table"></div> 

The problem is that if I use these checkboxes, the selection (blue) is anonymous and confusing.

Thanks.

+6
source share
2 answers

Another option is to reset the selection when the "select" event is fired:

 google.visualization.events.addListener(visualization, 'select', selectHandler); function selectHandler() { visualization.setSelection([]) } 

Here is an example: http://jsfiddle.net/Rxnty/

This immediately removes the selection without requiring redrawing.

+11
source

One way to achieve the desired effect is to tell the API which class to use when selecting a string, allowing you to specify the background-color string.

JS:

 options['cssClassNames'] = {} options['cssClassNames']['selectedTableRow'] = 'selected'; 

CSS

 .selected { background-color: white; } 

You can see that it is working on jsfiddle .

+2
source

Source: https://habr.com/ru/post/921933/


All Articles