By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,378 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

DataGrid column sorting

P: 12
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
Share this question for a faster answer!
Share on Google+

Post your reply

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