Cannot access DataTable.getNumberOfColumns()

42 views
Skip to first unread message

rishu oberoi

unread,
Aug 18, 2015, 4:53:50 PM8/18/15
to Google Visualization API
This is how I am creating my data table. Just including a snippet below. 

 link_wfc_core_stats_data = google.visualization.arrayToDataTable(dataArray);
calculatePercentagesWithGlobalFactor(link_wfc_core_stats_data,PIPELINE_LINK_ALL);
var link_wfc_core_stats_table = new google.visualization.Table(document.getElementById('link_wfc_core_stats_table'));
link_wfc_core_stats_table.draw(link_wfc_core_stats_data, table_options);

However, once the table is ready, when I try to use the table as - link_wfc_core_stats_table.getNumberOfColumns() - I get an error saying that the method getNumberOfColumns does not exist.

Why is that? 

Sergey Grabkovsky

unread,
Aug 18, 2015, 4:56:07 PM8/18/15
to Google Visualization API
Hi Rishu,

The Table visualization (google.visualization.Table) is a separate thing from the DataTable (google.visualization.DataTable, or google.visualization.arrayToDataTable). DataTables have getNumberOfColumns, but Tables don't. You're trying to call it on the Table (link_wfc_core_stats_table) instead of your DataTable (link_wfc_core_stats_data).

--
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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/2f71ed8a-1020-4a77-a820-59206c03f9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rishu oberoi

unread,
Aug 18, 2015, 5:01:48 PM8/18/15
to Google Visualization API
Thanks for your reply. I actually tried link_wfc_core_stats_data as well but getting the same error. But I tried a jsfiddle and I see that it works. Probably I am doing something else wrong. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}


On Tuesday, 18 August 2015 15:56:07 UTC-5, Sergey wrote:
Hi Rishu,

The Table visualization (google.visualization.Table) is a separate thing from the DataTable (google.visualization.DataTable, or google.visualization.arrayToDataTable). DataTables have getNumberOfColumns, but Tables don't. You're trying to call it on the Table (link_wfc_core_stats_table) instead of your DataTable (link_wfc_core_stats_data).

On Tue, Aug 18, 2015 at 4:53 PM rishu oberoi <rishu...@gmail.com> wrote:
This is how I am creating my data table. Just including a snippet below. 

 link_wfc_core_stats_data = google.visualization.arrayToDataTable(dataArray);
calculatePercentagesWithGlobalFactor(link_wfc_core_stats_data,PIPELINE_LINK_ALL);
var link_wfc_core_stats_table = new google.visualization.Table(document.getElementById('link_wfc_core_stats_table'));
link_wfc_core_stats_table.draw(link_wfc_core_stats_data, table_options);

However, once the table is ready, when I try to use the table as - link_wfc_core_stats_table.getNumberOfColumns() - I get an error saying that the method getNumberOfColumns does not exist.

Why is that? 

--
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 google-visualization-api+unsub...@googlegroups.com.

Sergey Grabkovsky

unread,
Aug 19, 2015, 9:37:45 AM8/19/15
to Google Visualization API
I'm pretty sure that jquery won't pass a datatable to your function. In your function, the variable 'link_wfc_core_stats_data' will be a click event, not a DataTable.

On Tue, Aug 18, 2015 at 5:01 PM rishu oberoi <rishu...@gmail.com> wrote:
Thanks for your reply. I actually tried link_wfc_core_stats_data as well but getting the same error. But I tried a jsfiddle and I see that it works. Probably I am doing something else wrong. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}


On Tuesday, 18 August 2015 15:56:07 UTC-5, Sergey wrote:
Hi Rishu,

The Table visualization (google.visualization.Table) is a separate thing from the DataTable (google.visualization.DataTable, or google.visualization.arrayToDataTable). DataTables have getNumberOfColumns, but Tables don't. You're trying to call it on the Table (link_wfc_core_stats_table) instead of your DataTable (link_wfc_core_stats_data).

On Tue, Aug 18, 2015 at 4:53 PM rishu oberoi <rishu...@gmail.com> wrote:
This is how I am creating my data table. Just including a snippet below. 

 link_wfc_core_stats_data = google.visualization.arrayToDataTable(dataArray);
calculatePercentagesWithGlobalFactor(link_wfc_core_stats_data,PIPELINE_LINK_ALL);
var link_wfc_core_stats_table = new google.visualization.Table(document.getElementById('link_wfc_core_stats_table'));
link_wfc_core_stats_table.draw(link_wfc_core_stats_data, table_options);

However, once the table is ready, when I try to use the table as - link_wfc_core_stats_table.getNumberOfColumns() - I get an error saying that the method getNumberOfColumns does not exist.

Why is that? 

--
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 google-visualizati...@googlegroups.com.
--
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 google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

Rishu Oberoi

unread,
Aug 19, 2015, 10:29:10 AM8/19/15
to google-visua...@googlegroups.com
I agree, I'm passing link_wfc_core_stats_data and not table now. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}

For some reason, I get the error saying getNumberOfColumns() is not a method, even when I pass data. 
What might be the reason?

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/_SSjfhVfuhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.



--
Regards
Rishupreet 

rishu oberoi

unread,
Aug 19, 2015, 11:43:05 AM8/19/15
to Google Visualization API
Attached a snapshot of the error I see. 

I agree, I'm passing link_wfc_core_stats_data and not table now. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}

For some reason, I get the error saying getNumberOfColumns() is not a method, even when I pass data. 
What might be the reason?



On Wednesday, 19 August 2015 09:29:10 UTC-5, rishu oberoi wrote:
I agree, I'm passing link_wfc_core_stats_data and not table now. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}

For some reason, I get the error saying getNumberOfColumns() is not a method, even when I pass data. 
What might be the reason?
On Wed, Aug 19, 2015 at 8:37 AM, 'Sergey Grabkovsky' via Google Visualization API <google-visualization-api@googlegroups.com> wrote:
I'm pretty sure that jquery won't pass a datatable to your function. In your function, the variable 'link_wfc_core_stats_data' will be a click event, not a DataTable.

On Tue, Aug 18, 2015 at 5:01 PM rishu oberoi <rishu...@gmail.com> wrote:
Thanks for your reply. I actually tried link_wfc_core_stats_data as well but getting the same error. But I tried a jsfiddle and I see that it works. Probably I am doing something else wrong. 
I am passing the data in a function as follows

 $( "#downloadCSV" ).click(function(link_wfc_core_stats_data) {//accessing the method here}


On Tuesday, 18 August 2015 15:56:07 UTC-5, Sergey wrote:
Hi Rishu,

The Table visualization (google.visualization.Table) is a separate thing from the DataTable (google.visualization.DataTable, or google.visualization.arrayToDataTable). DataTables have getNumberOfColumns, but Tables don't. You're trying to call it on the Table (link_wfc_core_stats_table) instead of your DataTable (link_wfc_core_stats_data).

On Tue, Aug 18, 2015 at 4:53 PM rishu oberoi <rishu...@gmail.com> wrote:
This is how I am creating my data table. Just including a snippet below. 

 link_wfc_core_stats_data = google.visualization.arrayToDataTable(dataArray);
calculatePercentagesWithGlobalFactor(link_wfc_core_stats_data,PIPELINE_LINK_ALL);
var link_wfc_core_stats_table = new google.visualization.Table(document.getElementById('link_wfc_core_stats_table'));
link_wfc_core_stats_table.draw(link_wfc_core_stats_data, table_options);

However, once the table is ready, when I try to use the table as - link_wfc_core_stats_table.getNumberOfColumns() - I get an error saying that the method getNumberOfColumns does not exist.

Why is that? 

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/_SSjfhVfuhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.



--
Regards
Rishupreet 
issue.png

Sergey Grabkovsky

unread,
Aug 19, 2015, 11:44:55 AM8/19/15
to google-visua...@googlegroups.com
It still doesn't look like you're passing the data, you're just using the same name but it will be a different thing. If you're doing exactly what you say you're doing, everything should work, but these issues usually come from user error. If you link to a page, I can tell you exactly what to fix, but from the one line you showed me, I still maintain that the variable "link_wfc_core_stats_data" isn't a DataTable, but a click event which won't have getNumberOfColumns() defined (because it's not a DataTable).

rishu oberoi

unread,
Aug 19, 2015, 1:46:33 PM8/19/15
to Google Visualization API
You are right, when I stopped passing link_wfc_core_stats_data in the click event, it worked fine. 
Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.

--
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 google-visualization-api+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/_SSjfhVfuhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.



--
Regards
Rishupreet 

--
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 google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages