473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1222

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

Similar topics

1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
3
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
0
by: Robert Brinson | last post by:
Hello all! I'm running .NET Framework 1.1 using VS.NET 2003. I've got a mystery with a DataGrid. Below is the definition of the DataGrid from my aspx page: </asp:datagrid><asp:datagrid...
11
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I...
2
by: Lars Netzel | last post by:
I have a Datagrid using the Edit/Update mode to alter data in the datasource. I needed to have a bit more flexible interface in the editmode with a design that couldn't work in the columns. So I...
4
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.