How to hide column in table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don Grover

    #1

    How to hide column in table

    I have a HTML table created using ASP as a web page.

    ie.

    HEADING1 HEADING2 HEADING3 etc...
    data 1 data2 data3 etc
    and so on

    How can I toggle hide / show the columns individually, anyone ever needed to
    do this and have any suggestions.



    Regards
    Don





  • Erwin Moller

    #2
    Re: How to hide column in table

    Don Grover wrote:
    [color=blue]
    > I have a HTML table created using ASP as a web page.
    >
    > ie.
    >
    > HEADING1 HEADING2 HEADING3 etc...
    > data 1 data2 data3 etc
    > and so on
    >
    > How can I toggle hide / show the columns individually, anyone ever needed
    > to do this and have any suggestions.
    >
    >
    >
    > Regards
    > Don[/color]

    Hi Don,

    Just make some switch or if/then construct to decide if you should output a
    column.

    You'll get something like:

    suppose col1, col2, etc contain 'on' or 'off', depending on the fact if you
    want to show them. (You didn't specify how that should work, so you'll have
    to cook up that part yourself.)

    .... looping here over the rows ....

    <tr>
    <%
    IF (col1='on') THEN
    %>
    <td>
    I have value <%= putithere %>
    </td>
    <%
    END IF
    %>
    </tr>

    ...... looping over the rows....


    And do that for every column.
    If you have a zillion column you better put the logic in an array and make
    the code smarter.


    Very possible I made some languagemistake s. My ASP got very rusty after I
    started using PHP. :-)

    Regards,
    Erwin Moller

    Comment

    • DJ WIce

      #3
      Re: How to hide column in table

      : > HEADING1 HEADING2 HEADING3 etc...
      : > data 1 data2 data3 etc
      : > and so on
      : >
      : > How can I toggle hide / show the columns individually, anyone ever
      needed
      : > to do this and have any suggestions.

      Set the style of the collom to be disabled to:
      style='display: none;'
      And when it may appear again:
      style='display: block;'

      You can loop over the table and take each 3rd (for example something like):

      var RowNumber = 3;
      var Elements = document.getEle mentByID('table ID').getElement ByTag('TD');
      for (i=RowNumber-1;i<Elements.le ngth;i=i+RowNum ber)
      {
      Elements[i].style='display :none;'
      }

      You can built in a switch to test the current display style and change it to
      block if it's none also.

      Wouter


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: How to hide column in table

        DJ WIce wrote:[color=blue]
        > Set the style of the collom to be disabled to:
        > style='display: none;'
        > And when it may appear again:
        > style='display: block;'[/color]

        "style" refers to object, according to the W3C-DOM Level 2 Style
        Specification, and the TD elements initial value for the CSS
        "display" property is "table-cell", not "block". Thus it should
        be

        style.display = "none";

        and

        style.display = "table-cell";

        Else it will only work in non-standards-compliant UAs, if that.


        PointedEars

        P.S.: Your "From" header is borken.

        Comment

        • DU

          #5
          Re: How to hide column in table

          Thomas 'PointedEars' Lahn wrote:
          [color=blue]
          > DJ WIce wrote:
          >[color=green]
          >>Set the style of the collom to be disabled to:
          >> style='display: none;'
          >>And when it may appear again:
          >> style='display: block;'[/color]
          >
          >
          > "style" refers to object, according to the W3C-DOM Level 2 Style
          > Specification, and the TD elements initial value for the CSS
          > "display" property is "table-cell", not "block".[/color]

          According to the W3C-DOM Level 2 Style Specification, the <col> element
          initial value for the CSS "display" property is "table-column", not
          "block" and not "table-cell". Now, the subject line was about column in
          table...

          Thus it should[color=blue]
          > be
          >
          > style.display = "none";
          >
          > and
          >
          > style.display = "table-cell";
          >[/color]

          ....<cough clearing my throat>...
          and style.display = "table-column";
          [color=blue]
          > Else it will only work in non-standards-compliant UAs, if that.
          >
          >
          > PointedEars
          >
          > P.S.: Your "From" header is borken.[/color]

          and if
          style.display = "table-column";
          does not work in MSIE 6 for Windows, then you can use
          style.display = "block";
          so that the code will work for roughly 60% of all web users out there
          (that's just a little bit more than a few hundreds of millions of people
          on this planet) ... until MSIE 7 for Windows correct all this.

          According to

          and

          display:table-column
          is not supported by MSIE 5+ nor Mozilla 1.4.

          Nevertheless, one can code to workaround all these difficulties. Here's
          a page (local version without brinkster banner ads will validate
          perfectly) which will work overall rather well in Mozilla 1.6, Opera
          7.50 PR1 build 3494, MSIE 6 for Windows, K-meleon 0.8.2, NS 7.1,
          Firebird 0.8+ (build 20040120), MyIE2 vers. 0.9.12 with Gecko 1.5:



          Modifying the table column structure *and* the table row structure at
          the same time will not produce correct layout. But if the user only
          tries to modify either only the column structure or only the row
          structure, then the layout will be correct. I still need to tweak the
          code and tune a few things in the functions to make it more robust. I'm
          still working on that file so I don't want to hear nitpicking comments.

          I have another demo page where one can show, hide or collapse table
          sections like the thead, tbody and tfoot.

          Pointed ears, you could have replied in a much more constructive manner.
          Again, you focus on little things which can only annoy others or
          contribute/lead to clashing <plonk> noises.

          DU

          Comment

          • Randy Webb

            #6
            Re: How to hide column in table

            DU wrote:

            <--snip-->
            [color=blue]
            >
            > http://www10.brinkster.com/doctorunc...nCollapse.html[/color]

            <--snip-->
            [color=blue]
            > I'm still working on that file so I don't want to hear nitpicking comments.[/color]

            No nitpicking - its great so far. Can you post back when its finished?
            I noticed two things (probably nitpicky) but want to wait until its
            finished.


            Also, any chance of you re-uploading the ScrollingTableI nMSIE.html file?

            I have hunted it for 4 days now and finally found it in the archive.org
            site:

            <URL:

            />

            Or, do you mind me using it for a demo page with credit given?



            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            • DU

              #7
              Re: How to hide column in table

              Randy Webb wrote:
              [color=blue]
              > DU wrote:
              >
              > <--snip-->
              >[color=green]
              >>
              >> http://www10.brinkster.com/doctorunc...nCollapse.html[/color]
              >
              >
              >
              > <--snip-->
              >[color=green]
              >> I'm still working on that file so I don't want to hear nitpicking
              >> comments.[/color]
              >
              >
              > No nitpicking - its great so far. Can you post back when its finished?
              > I noticed two things (probably nitpicky) but want to wait until its
              > finished.
              >
              >
              > Also, any chance of you re-uploading the ScrollingTableI nMSIE.html file?
              >[/color]

              Nope. That was a first draft, first version of the file. Once I was
              satisfied with my latest version and could not see how I could further
              tune it or improve it, then I *renamed* it and removed
              ScrollingTableI nMSIE.html

              Now, that file is now:



              and will (should?) work accordingly with NS 7.1, Mozilla 1.3+,
              Opera 7.x, MSIE 6, etc.


              [color=blue]
              > I have hunted it for 4 days now and finally found it in the archive.org
              > site:
              >
              > <URL:
              > http://web.archive.org/web/200306082...bleInMSIE.html
              > />
              >
              > Or, do you mind me using it for a demo page with credit given?
              >
              >
              >[/color]

              ...with credit given, ok, no problem. Thanks for asking. I appreciate
              good ethics in such situation.

              DU
              --
              P.S.: If you want to give more, I'll give you my PayPal address :)
              Just kidding. :)

              Comment

              • DU

                #8
                Re: How to hide column in table

                Randy Webb wrote:

                [color=blue]
                >
                > Also, any chance of you re-uploading the ScrollingTableI nMSIE.html file?
                >
                > I have hunted it for 4 days now and finally found it in the archive.org
                > site:
                >
                > <URL:
                > http://web.archive.org/web/200306082...bleInMSIE.html
                > />
                >
                > Or, do you mind me using it for a demo page with credit given?
                >
                >
                >[/color]

                The best thing you can do about scrolling tbody is to ask, demand
                browsers to support it without any need of javascript or complex hacks.
                Scrolling tbody is quite useful, you know.
                I personally filed bug 123296 at Opera's Bug Tracking Database on this.
                So if you want to support a permanent, reliable, real cross-browser
                solution, then log into opera.general and/or opera.wishlist and/or
                opera.page-authoring and demand that Opera supports overflow:auto on
                defined tbody length.

                See #4 here and the included reference to the W3C HTML 4.01



                "(...) This division [THEAD, TFOOT and TBODY elements] enables user
                agents to support scrolling of table bodies independently of the table
                head and foot."

                HTML 4.01 11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements

                I filed the same bug for MSIE 6 in that corresponding section.

                DU

                Comment

                • DJ WIce

                  #9
                  Re: How to hide column in table

                  : P.S.: Your "From" header is borken.
                  To avoid "Someone have replied to your message" from some website that
                  copies this archieve.

                  Wouter


                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: How to hide column in table

                    DJ WIce wrote:
                    [color=blue]
                    > : P.S.: Your "From" header is borken.
                    > To avoid "Someone have replied to your message"
                    > from some website that copies this archieve.[/color]

                    That's your problem. Use filters.

                    <http://www.interhack.n et/pubs/munging-harmful/>


                    PointedEars

                    Comment

                    Working...