Once you disable sorting, I would not expect the table to be regenerated after clicking a column header (though it sounds like you are saying it is), nor would I expect a 'sort' event to be triggered (though it sounds like you were expecting it would).
It is unfortunate that the table does not have a built-in way to identify each row, or each column. This should be something we fix at some point because it fairly easy to add identifying information, and it is difficult for users to work around the lack. The easiest way currently to determine which row the user has clicked on is to work with the selection data returned by getSelection(). Is that not enough to go on? It is more work to figure out which column the user has clicked on, something else we should fix. Recreating changes to the table after each update of the table seems like something I would not attempt myself. It would require at least figuring out which data row each table row corresponds to, and once you know the data row, that ought to be enough. Perhaps you want to say more about why you have gone down this path. On Mon, May 8, 2017 at 9:04 PM, Weii Wang <[email protected]> wrote: > Hi Daniel, > > Thanks a lot for the clarification and the hint. > What I want to do is to give every row in the table an id. > This is achieved by: > google.visualization.events.addListener(SPRITE_table, 'ready', function > () { > $('.google-visualization-table-table tbody > tr').each(function (e){ > var idx = $('td:nth-child(1) span', this).attr('setid'); > var ue = $('td:nth-child(2) span', this).attr('realuetxt'); > var id; > if(ue == null){ > id = idx; > }else{ > id = idx + '_' + ue; > } > $(this).attr('id', id); > $(this).attr('class', idx); > }); > }); > > But whenever the <th> is clicked, the id I set above is gone. > Even when I set option : 'sort': 'disabled' still the id is gone whenever > <th> is clicked. > So I thought maybe I should do something with the 'sort' event like assign > the ID again for each row but nothing happened. > I added below code outside or inside the ready listener both of them did > not do anything. > google.visualization.events.addListener(SPRITE_table, 'sort', function(e){ > console.log('sort event triggered!'); > > }); > > Can you please shed some light > > Thanks! and BR, > Winnie > > > On Friday, May 5, 2017 at 7:43:44 PM UTC-7, Daniel LaLiberte wrote: >> >> In order for a change of options (such as disabling sorting) to take >> effect, currently you would have to draw it again, but if you want it >> sorted the same as it was, you would have to recreate that order somehow >> (either reorder your datatable, or invoke the same sorting actions on the >> table). So unfortunately, there is no way to do what I believe you are >> asking for, at least not in the Table chart functionality. >> >> But you could probably override the click event handler that causes the >> sorting actions by the user, with suitable DOM manipulations. >> >> On Fri, May 5, 2017 at 8:20 PM, Weii Wang <[email protected]> wrote: >> >>> Hello, >>> >>> I have a table chart already drawn, but want to disable sorting after a >>> checkbox is checked. >>> Is there a method to change option after the table is ready. >>> >>> var SPRITE_table = new google.visualization.ChartWrapper({ >>> 'chartType': 'Table', >>> 'containerId': 'sprite_table', >>> 'options' : { >>> 'showRowNumber' : 'false', >>> 'allowHtml': 'true', >>> //'width': '2000', >>> 'cssClassNames': cssClassNames >>> }, >>> 'view': {'columns': [20,0,1,2,3,4,5,6,7,8,9,10,11]} >>> }); >>> google.visualization.events.addListener(SPRITE_table, 'ready', function >>> () { >>> * if($('#mycheckbox').is(':checked')){* >>> * // disable sorting for SPRITE_table* >>> * }* >>> )}; >>> >>> Thanks, >>> Weii >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google Visualization API" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/grou >>> p/google-visualization-api. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/google-visualization-api/7ce33d0a-1266-44fe-9a3e-0da61b >>> a4e492%40googlegroups.com >>> <https://groups.google.com/d/msgid/google-visualization-api/7ce33d0a-1266-44fe-9a3e-0da61ba4e492%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> >> [email protected] 5CC, Cambridge MA >> > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to google-visualization-api@ > googlegroups.com. > Visit this group at https://groups.google.com/ > group/google-visualization-api. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/google-visualization-api/540a34e7-d451-4b20-b243- > 151a2f2a4800%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/540a34e7-d451-4b20-b243-151a2f2a4800%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> [email protected] <[email protected]> 5CC, Cambridge MA -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJP0H2iYMjLNe9EDVZMowj5gc3utHwfMcYyX%3DWfAcM%3DXLw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
