Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:51:06+00:00 2026-06-08T08:51:06+00:00

I have created a table using gviz_api. The table contains columns composed of string

  • 0

I have created a table using gviz_api. The table contains columns composed of string values and number values. The api automatically chooses the order in which columns render themselves; however, I would like the rendering to happen in the same order as I provide the description.

To create the table, I passed in a description, which is a dictionary and the data, which is a list of dictionaries for each row. I think that because the description is a dictionary, ordering is not explicit and so can be chosen at random. Is there a way to force the api to use the order of the columns that I specify in the description or any other way?

Here’s the example description and data code that I have:

descr = {'field1': ('string', 'Field1'),
         'field2': ('number', 'Field2'),
         'field3': ('string', 'Field3'),
         'field4': ('string', 'Field3')}
data = [{'field1': 'value1-1', 'field2': value1-2, 'field3': 'value1-3', 'field4': 'value1-4},
        {'field1': 'value2-1', 'field2': value2-2, 'field3': 'value2-3', 'field4': 'value2-4}]

data_table = gviz_api.DataTable(description)
data_table.LoadData(data)
code = data_table.ToJSCode(stats_type_name + '_data')

And the order in which things actually get rendered:

field3     field2      field1     field4
value1-3   value1-2    value1-1   value1-4
value2-3   value2-2    value2-1   value2-4

The order in which I would like things to appear is the same as I specify in the description:

field1     field2      field3     field4
value1-1   value1-2    value1-3   value1-4
value2-1   value2-2    value2-3   value2-4
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:51:08+00:00Added an answer on June 8, 2026 at 8:51 am

    So I kind of found a hack solution. From observation, I noticed that gviz_api uses alphabetical ordering when adding columns to the table. My column names had different labels (i.e. second entry in (‘string’, ‘label’) that were not in alphabetical order. To fix it, I prepended the label name with a number (i.e. (‘string’, ‘1label’)) to ensure the order of the columns to be how I want them to.

    If anyone else finds a less hackier solution, please let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a table using qtablewidget. The table contains a few buttons. I
I am using SQL Server 2005. I have created a table with the columns
I have created one table using the below command: create table Table1( Id int
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's
I have created many tables using <table> tag but don't know how to get
I have a table created in sql. but in my application I am using
I have a table called Tournaments which is created using the EF code first
I have created table and inserted values as below. create table mytable (id INT,
I have created a table in Visual Studio. That table has two columns. First
I have created an sqlite table using the following statement: CREATE TABLE IF NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.