Special Datagrid sort
-
Hi, I have a list of records. Those records have a field called Progress. There are 4 Progresses. 'Pending', 'Work In Progress' and 'Completed'. If I sort by Progress in ASCENDING, then the order will be: Completed Pending Work In Progress If I sort by Progress in DESCENDING, then the order will be: Work In Progress Pending Completed I need PENDING to be at the top. So that all the records which are PENDING will be at the top and the rest can be sorted as normal. Any ideas how I can do this? Thank you.
-
Hi, I have a list of records. Those records have a field called Progress. There are 4 Progresses. 'Pending', 'Work In Progress' and 'Completed'. If I sort by Progress in ASCENDING, then the order will be: Completed Pending Work In Progress If I sort by Progress in DESCENDING, then the order will be: Work In Progress Pending Completed I need PENDING to be at the top. So that all the records which are PENDING will be at the top and the rest can be sorted as normal. Any ideas how I can do this? Thank you.
Add a new column to the DataTable in memory and set the value based off the Progress column. That way you can set Pending = 1, work in progress = 2, completed = 3. Then in your code take the dataview and sort it. dim dv as DataView = dataTable.DefaultView dv.Sort = "NewSortColumn" Or you could just add a Sort column to your table in the database as well. Or you could move the Process column into its own table and just stored the processid in your table you are returning. Hope that helps. Ben
-
Hi, I have a list of records. Those records have a field called Progress. There are 4 Progresses. 'Pending', 'Work In Progress' and 'Completed'. If I sort by Progress in ASCENDING, then the order will be: Completed Pending Work In Progress If I sort by Progress in DESCENDING, then the order will be: Work In Progress Pending Completed I need PENDING to be at the top. So that all the records which are PENDING will be at the top and the rest can be sorted as normal. Any ideas how I can do this? Thank you.
Or sort based on len(Progress) bcos it has the least length.
Regards, Arun Kumar.A
-
Or sort based on len(Progress) bcos it has the least length.
Regards, Arun Kumar.A
That's a really bad idea. I'd fire you if you wrote code like that. What if the status enums change? How about localization changes in the text of the enums??
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
That's a really bad idea. I'd fire you if you wrote code like that. What if the status enums change? How about localization changes in the text of the enums??
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Sorry , I didn't think on these effects. Anyway, thank U very much.
Regards, Arun Kumar.A
-
Hi, I have a list of records. Those records have a field called Progress. There are 4 Progresses. 'Pending', 'Work In Progress' and 'Completed'. If I sort by Progress in ASCENDING, then the order will be: Completed Pending Work In Progress If I sort by Progress in DESCENDING, then the order will be: Work In Progress Pending Completed I need PENDING to be at the top. So that all the records which are PENDING will be at the top and the rest can be sorted as normal. Any ideas how I can do this? Thank you.
Silly me .. I found the easiest and most reliable way of doing this.. Simply add another column in the Database called Progress Number. Pending will be 1, Work In Progress will be 2.. etc.. And then simply sort by "ProgressNumber" Thank you guys for the help.