471,350 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

DataGrid column sorting

Boa constructor
Windows XP
python 2.3


How do you sort data alphabetically in the grid column.

In one of the previous post i found a link
[HTML]http://dotnetjunkies.com/Tutorial/E169C6D4-D335-4D2B-AE3F-918EE3161815.dcik[/HTML]
its not in python so can anyone please explain the logic behind it.

it was (fairly)easy to sort the datagrid column if the column contained just numbers.
( double click event on a particular column label)
Expand|Select|Wrap|Line Numbers
  1.  
  2.             counter = 1
  3.             Number_of_rows_Grid1 = self.grid1.GetNumberRows()
  4.             self.grid1.InsertRows(pos=Number_of_rows_Grid1, numRows=1)
  5.             for rows1 in range (0, Number_of_rows_Grid1-1):    
  6.                 P1 = self.grid1.GetCellValue(rows1, clicked_column_number)
  7.                 if (P1):
  8.                     P1 = float(P1)
  9.                 else:
  10.                     P1 = 0.00
  11.                 for rows2 in range (counter, Number_of_rows_Grid1-1):
  12.                     P2 = self.grid1.GetCellValue(rows2, clicked_column_number)
  13.                     if (P2):
  14.                         P2 = float(P2)
  15.                     else:
  16.                         P2 = 0.00
  17.  
  18.                     if (P2<P1):
  19.                         for col in range (0, 10):
  20.                             self.grid1.SetCellValue(Number_of_rows_Grid1, col, self.grid1.GetCellValue(rows1, col))
  21.                             self.grid1.SetCellValue(rows1, col, self.grid1.GetCellValue(rows2, col))
  22.                             self.grid1.SetCellValue(rows2, col, self.grid1.GetCellValue(Number_of_rows_Grid1, col))
  23.                         P1 = P2
  24.                 counter = counter + 1
  25.             self.grid1.DeleteRows(pos=Number_of_rows_Grid1, numRows=1)
Nov 29 '07 #1
0 1145

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Sargas Atum | last post: by
3 posts views Thread by melanieab | last post: by
5 posts views Thread by John Richardson | last post: by
reply views Thread by Robert Brinson | last post: by
11 posts views Thread by rkbnair | last post: by
2 posts views Thread by Lars Netzel | last post: by
3 posts views Thread by TPhelps | last post: by
4 posts views Thread by Ambica Jain | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.