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. Web Development
  3. Javascript Sorting Problem

Javascript Sorting Problem

Scheduled Pinned Locked Moved Web Development
javascriptcomalgorithmstoolshelp
9 Posts 3 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.
  • N Offline
    N Offline
    Nick Parker
    wrote on last edited by
    #1

    Ok here is the situation. I need to be able to sort a table of data that is returned in a paged recordset layout. The idea I am trying to create for the user is that if they click on the "Head" of the column once the data will be sorted descending, again and it will be sorted ascending. I have found a script on another site to do this however it doesn't work in Netscape and the application I am working on requires browser compliance across the board. Does anyone have any suggestions? Thanks in advance. P.S. - Right now the application will sort the entire contents of the returning results, I only want to sort descending or ascending of the 10 records per page that is being displayed. Nick Parker

    M 1 Reply Last reply
    0
    • N Nick Parker

      Ok here is the situation. I need to be able to sort a table of data that is returned in a paged recordset layout. The idea I am trying to create for the user is that if they click on the "Head" of the column once the data will be sorted descending, again and it will be sorted ascending. I have found a script on another site to do this however it doesn't work in Netscape and the application I am working on requires browser compliance across the board. Does anyone have any suggestions? Thanks in advance. P.S. - Right now the application will sort the entire contents of the returning results, I only want to sort descending or ascending of the 10 records per page that is being displayed. Nick Parker

      M Offline
      M Offline
      mortrr
      wrote on last edited by
      #2

      I assume you're talking about requesting the data again from the database, and not using dhtml (which could be he only reason why the script doesn't work with netscape) to sort the single page. Getting your 10 records from the database, in the right order within a single page, can only be done by requesting those specific records by ID. So you'll have to send the IDs of the records back to the server (hidden input) with the sort field. MS SQL: "SELECT * FROM myTable WHERE ID IN ("+myIDs+") ORDER BY "+orderField myIDs contains comma-separated IDs. Paging after sorting using a different field, will be a bit confusing though, as the user whould have to return to your default sort-order. - Morten

      N 1 Reply Last reply
      0
      • M mortrr

        I assume you're talking about requesting the data again from the database, and not using dhtml (which could be he only reason why the script doesn't work with netscape) to sort the single page. Getting your 10 records from the database, in the right order within a single page, can only be done by requesting those specific records by ID. So you'll have to send the IDs of the records back to the server (hidden input) with the sort field. MS SQL: "SELECT * FROM myTable WHERE ID IN ("+myIDs+") ORDER BY "+orderField myIDs contains comma-separated IDs. Paging after sorting using a different field, will be a bit confusing though, as the user whould have to return to your default sort-order. - Morten

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        Morten Rasmussen wrote: I assume you're talking about requesting the data again from the database I am actually looking into methods that will allow me to sort the data without returning to the server. I do have a script that does this but it is only effective in IE. Thanks Nick Parker

        M 1 Reply Last reply
        0
        • N Nick Parker

          Morten Rasmussen wrote: I assume you're talking about requesting the data again from the database I am actually looking into methods that will allow me to sort the data without returning to the server. I do have a script that does this but it is only effective in IE. Thanks Nick Parker

          M Offline
          M Offline
          mortrr
          wrote on last edited by
          #4

          It can be done in the browser, including NS (but only NS6). Give all cells an ID. Cell_00_00 - Cell_00_01 - Cell_00_02 Cell_01_00 - Cell_01_01 - Cell_01_02 Cell_02_00 - Cell_02_01 - Cell_02_02 Create an Array for client-side javascript that contains all data (no need to read data from the table, before each sort). On click, sort the data (same array or to new array) and insert cell by cell. - Morten

          N 1 Reply Last reply
          0
          • M mortrr

            It can be done in the browser, including NS (but only NS6). Give all cells an ID. Cell_00_00 - Cell_00_01 - Cell_00_02 Cell_01_00 - Cell_01_01 - Cell_01_02 Cell_02_00 - Cell_02_01 - Cell_02_02 Create an Array for client-side javascript that contains all data (no need to read data from the table, before each sort). On click, sort the data (same array or to new array) and insert cell by cell. - Morten

            N Offline
            N Offline
            Nick Parker
            wrote on last edited by
            #5

            I beleive we are basing our tests off the earlier versions of Netscape 4. Seem to run into a brick wall everytime. :mad: Nick Parker

            M 1 Reply Last reply
            0
            • N Nick Parker

              I beleive we are basing our tests off the earlier versions of Netscape 4. Seem to run into a brick wall everytime. :mad: Nick Parker

              M Offline
              M Offline
              mortrr
              wrote on last edited by
              #6

              If you don't have any form elements in the table, you can try: http://www.mattkruse.com/javascript/sorttable/index.html It's not extremely stable in NS 4.x, but it works if you don't click around too fast (as all NS layering). The buttom sample works in NS. Not the top one, as it contains form elements. You must have a very insistent customer, since you're trying to implement it for NS 4.0x The user base is propably below 1 percent now, and why ruin the "experience" for users keeping up to date? - Morten

              N 1 Reply Last reply
              0
              • M mortrr

                If you don't have any form elements in the table, you can try: http://www.mattkruse.com/javascript/sorttable/index.html It's not extremely stable in NS 4.x, but it works if you don't click around too fast (as all NS layering). The buttom sample works in NS. Not the top one, as it contains form elements. You must have a very insistent customer, since you're trying to implement it for NS 4.0x The user base is propably below 1 percent now, and why ruin the "experience" for users keeping up to date? - Morten

                N Offline
                N Offline
                Nick Parker
                wrote on last edited by
                #7

                Morten Rasmussen wrote: The user base is propably below 1 percent now, and why ruin the "experience" for users keeping up to date? You are probably correct; the company I work for represents a conglomerate of independent telephone companies, none of which we can require them to use IE. Nick Parker

                M 1 Reply Last reply
                0
                • N Nick Parker

                  Morten Rasmussen wrote: The user base is propably below 1 percent now, and why ruin the "experience" for users keeping up to date? You are probably correct; the company I work for represents a conglomerate of independent telephone companies, none of which we can require them to use IE. Nick Parker

                  M Offline
                  M Offline
                  mortrr
                  wrote on last edited by
                  #8

                  Still, if you have to use hours upon hours implementing a single feature that will at best work flakily in NS 4.x for what is most likely a small userbase (even in phone companies - unless they're using OS/2), the time could be used better developing other features. To get the "tablesort" to work a bit better in NS, you could disable the click event for the coloumn-headings until the table is redrawn. - Morten

                  L 1 Reply Last reply
                  0
                  • M mortrr

                    Still, if you have to use hours upon hours implementing a single feature that will at best work flakily in NS 4.x for what is most likely a small userbase (even in phone companies - unless they're using OS/2), the time could be used better developing other features. To get the "tablesort" to work a bit better in NS, you could disable the click event for the coloumn-headings until the table is redrawn. - Morten

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Morten Rasmussen wrote: for what is most likely a small userbase Unfortunately we cover 147 independent telephone companies in Iowa so we do have quite a large user base. :)

                    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