Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Special Datagrid sort

Special Datagrid sort

Scheduled Pinned Locked Moved Visual Basic
jsonquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dayekh
    wrote on last edited by
    #1

    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.

    K A D 3 Replies Last reply
    0
    • D Dayekh

      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.

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D Dayekh

        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.

        A Offline
        A Offline
        Arun Immanuel
        wrote on last edited by
        #3

        Or sort based on len(Progress) bcos it has the least length.

        Regards, Arun Kumar.A

        D 1 Reply Last reply
        0
        • A Arun Immanuel

          Or sort based on len(Progress) bcos it has the least length.

          Regards, Arun Kumar.A

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            A Offline
            A Offline
            Arun Immanuel
            wrote on last edited by
            #5

            Sorry , I didn't think on these effects. Anyway, thank U very much.

            Regards, Arun Kumar.A

            1 Reply Last reply
            0
            • D Dayekh

              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.

              D Offline
              D Offline
              Dayekh
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups