Index: /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/browser/viewworksheetview.py
===================================================================
--- /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/browser/viewworksheetview.py	(revision 2667)
+++ /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/browser/viewworksheetview.py	(revision 2668)
@@ -52,25 +52,27 @@
         """
         """
+        table = ''
         feed = self.getFeed(ssh_id, wsh_id, startrow_idx)
         if isinstance(feed, SpreadsheetsListFeed):
-            indx_keys = filter(None, [elem['select_title'] for elem in self.context.title_column])
-            titles_columns = filter(None, [self.context.order_columns[int(i)] for i in indx_keys])
-
-            # Prepare table
-            table = "<table id=\"sshwsh\">"
-            table += "<tr>"
-            table += ''.join(["<th>%s</th>" % key for key in titles_columns])
-            table += "</tr>"
-            for i, entry in enumerate(feed.entry):
-                if i+1 > startrow_idx:
-                    td_row = "<tr>"
-                    for key in titles_columns:
-                        td_row += "<td>%s</td>" \
-                            % (not (entry.custom[key].text == 'None') and entry.custom[key].text or '')
-                    td_row += "</tr>\n"
-                    table += td_row
-            table += "</table>"
-        else:
-            table = ''
+            # akc is a list of keys of all columns. The context is GSpreadsheet content type
+            akc = self.context.all_keys_columns
+            # key_title_columns is list of tuples with two elements (column_key, column_title or column_key)
+            key_title_columns = [(e['column_key'], e['column_title'] or e['column_key'])
+                for e in self.context.order_columns if e['column_key'] in akc]
+            if key_title_columns:
+                # Prepare table
+                table = "<table id=\"sshwsh\">"
+                table += "<tr>"
+                table += ''.join(["<th>%s</th>" % el[1] for el in key_title_columns])
+                table += "</tr>"
+                for i, entry in enumerate(feed.entry):
+                    if i >= startrow_idx:
+                        td_row = "<tr>"
+                        for key in zip(*key_title_columns)[0]:
+                            td_row += "<td>%s</td>" \
+                                % (not (entry.custom[key].text == 'None') and entry.custom[key].text or '')
+                        td_row += "</tr>\n"
+                        table += td_row
+                table += "</table>"
         return table
 
@@ -84,5 +86,5 @@
         try:
             feed = self.sh_client.GetListFeed(ssh_id, wksht_id=wsh_id, query=self.query)
-            self.context.order_columns = len(feed.entry) and feed.entry[0].custom.keys() or []
+            self.context.all_keys_columns = len(feed.entry) and feed.entry[0].custom.keys() or []
         except Exception:
             logException('GetListFeed function call: '
Index: /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/content/gspreadsheet.py
===================================================================
--- /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/content/gspreadsheet.py	(revision 2667)
+++ /quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/content/gspreadsheet.py	(revision 2668)
@@ -10,4 +10,5 @@
 from Products.DataGridField import DataGridField, DataGridWidget
 from Products.DataGridField.SelectColumn import SelectColumn
+from Products.DataGridField.Column import Column
 
 from quintagroup.gdocs.spreadsheet import spreadsheetMessageFactory as _
@@ -52,18 +53,19 @@
 
     DataGridField(
-        name='title_column',
+        name='order_columns',
         searchable = True,
         languageIndependent=True,
         storage=atapi.AnnotationStorage(),
-        columns=("select_title",),
+        columns=("column_key", "column_title"),
         widget = DataGridWidget(
             label = _(
-                u'label_title_column',
-                default=u'Titles of columns'),
+                u'label_order_column',
+                default=u'Ordering columns'),
             description=_(
-                u'help_title_column',
-                default=u"Choose titles of columns"),
+                u'help_order_column',
+                default=u"Choose keys of columns and enter them titles"),
             columns={
-                'select_title' : SelectColumn("Titles of columns", vocabulary="getTitleColumnVocabulary"),
+                'column_key' : SelectColumn("Key of column", vocabulary="getKeyColumnVocabulary"),
+                'column_title' : Column("Title of column"),
             },
         ),
@@ -83,5 +85,5 @@
 
 class GSpreadsheet(base.ATCTContent):
-    """ Lets you select google spreadsheet worksheet id and choose title of columns """
+    """ Lets you select google spreadsheet id, worksheet id, choose keys of columns and define them title """
     implements(IGSpreadsheet)
 
@@ -89,17 +91,17 @@
     schema = GSpreadsheetSchema
 
-    order_columns = []
+    all_keys_columns = []
     title = atapi.ATFieldProperty('title')
     description = atapi.ATFieldProperty('description')
     spreadsheet_id = atapi.ATFieldProperty('spreadsheet_id')
     worksheet_id = atapi.ATFieldProperty('worksheet_id')
-    title_column = atapi.ATFieldProperty('title_column')
+    order_columns = atapi.ATFieldProperty('order_columns')
 
     # -*- Your ATSchema to Python Property Bridges Here ... -*-
 
-    def getTitleColumnVocabulary(self):
-        """ Get a list of titles of columns """
+    def getKeyColumnVocabulary(self):
+        """ Get a list of keys of columns """
         return atapi.DisplayList(
-            ([('%s'%i, t) for i,t in enumerate(self.order_columns)])
+            ([(t, t) for t in self.all_keys_columns])
         )
 
