grid javascript

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

    #1

    grid javascript

    Hi,

    any excel like grid javascript which is stable and fast to load thousand of rows data ? can it have F2 function to popup another window ? can validate cell value when cursor move away that cell ?

    Either free or low developer license with royalty-free distributed with web application.

    TQ.
    Regards
    Hoe
    tnhoe@pc.jaring .my
  • michael elias

    #2
    Re: grid javascript

    i'm working on it, ready in 2 months

    Comment

    • tnhoe

      #3
      Re: grid javascript

      "michael elias"

      well, plz drop me more details when you are ready.

      TQ
      hoe


      Comment

      • Russell Campbell

        #4
        Re: grid javascript

        Really? That would be neat.

        After seeing your response I wondered if you're the one to ask this: where
        can I find a JavaScript to put commas in a number as it's type into an HTML
        textbox? I searched the web for such a script and I find a bunch that work
        (I guess) if you want the user to enter the value, then click a button to
        format the entry. But that's a lame user interface. I need this to happen
        as they type. I tried to modify a few, but I'm still new to JavaScript, so
        I didn't have much success. Do you know of such a script?

        Thanks,

        Russell Campbell

        "michael elias" <michaelelias88 @gmail.com> wrote in message
        news:1110899874 .181327.91180@g 14g2000cwa.goog legroups.com...[color=blue]
        > i'm working on it, ready in 2 months
        >[/color]


        Comment

        • McKirahan

          #5
          Re: grid javascript

          "Russell Campbell" <nospam@byteme. com> wrote in message
          news:wNHZd.4629 $qW.2822@newsre ad3.news.atl.ea rthlink.net...[color=blue]
          > Really? That would be neat.
          >
          > After seeing your response I wondered if you're the one to ask this:[/color]
          where[color=blue]
          > can I find a JavaScript to put commas in a number as it's type into an[/color]
          HTML[color=blue]
          > textbox? I searched the web for such a script and I find a bunch that[/color]
          work[color=blue]
          > (I guess) if you want the user to enter the value, then click a button to
          > format the entry. But that's a lame user interface. I need this to[/color]
          happen[color=blue]
          > as they type. I tried to modify a few, but I'm still new to JavaScript,[/color]
          so[color=blue]
          > I didn't have much success. Do you know of such a script?
          >
          > Thanks,
          >
          > Russell Campbell[/color]


          Will this help?

          <html>
          <head>
          <title>commas.h tm</title>
          <script type="text/javascript">
          function commas(that) {
          var temp = "";
          var what = that.value.repl ace(/,/g,"");
          if (what.length == 0) return;
          for (i=0; i<what.length; i++) {
          if (i > 0 && i % 3 == 0) temp += ",";
          temp += what.charAt(i);
          }
          that.value = temp;
          }
          </script>
          </head>
          <body>
          <form>
          <input type="text" name="numb"
          style="text-align:right"
          onkeyup="commas (this)">
          <input type="reset" value="Clear">
          </form>
          </body>
          </html>

          Of course, JavaScript has to be enabled.


          Comment

          • Russell Campbell

            #6
            Re: grid javascript

            Yes, that does it for integers. Thanks. I did notice that if you enter
            123456789.00 then you get 123,456,789,.00

            However, in this case the user will only be entering positive integer
            values, so I'm not too concerned about that issue (though if you wanted to
            submit a corrected script, I would not object <g>).

            Thanks again - especially for the quick reply!

            "McKirahan" <News@McKirahan .com> wrote in message
            news:8-WdnQJu9d1dzqrfR Vn-2g@comcast.com. ..[color=blue]
            > "Russell Campbell" <nospam@byteme. com> wrote in message
            > news:wNHZd.4629 $qW.2822@newsre ad3.news.atl.ea rthlink.net...[color=green]
            >> Really? That would be neat.
            >>
            >> After seeing your response I wondered if you're the one to ask this:[/color]
            > where[color=green]
            >> can I find a JavaScript to put commas in a number as it's type into an[/color]
            > HTML[color=green]
            >> textbox? I searched the web for such a script and I find a bunch that[/color]
            > work[color=green]
            >> (I guess) if you want the user to enter the value, then click a button to
            >> format the entry. But that's a lame user interface. I need this to[/color]
            > happen[color=green]
            >> as they type. I tried to modify a few, but I'm still new to JavaScript,[/color]
            > so[color=green]
            >> I didn't have much success. Do you know of such a script?
            >>
            >> Thanks,
            >>
            >> Russell Campbell[/color]
            >
            >
            > Will this help?
            >
            > <html>
            > <head>
            > <title>commas.h tm</title>
            > <script type="text/javascript">
            > function commas(that) {
            > var temp = "";
            > var what = that.value.repl ace(/,/g,"");
            > if (what.length == 0) return;
            > for (i=0; i<what.length; i++) {
            > if (i > 0 && i % 3 == 0) temp += ",";
            > temp += what.charAt(i);
            > }
            > that.value = temp;
            > }
            > </script>
            > </head>
            > <body>
            > <form>
            > <input type="text" name="numb"
            > style="text-align:right"
            > onkeyup="commas (this)">
            > <input type="reset" value="Clear">
            > </form>
            > </body>
            > </html>
            >
            > Of course, JavaScript has to be enabled.
            >
            >[/color]


            Comment

            • Russell Campbell

              #7
              Re: grid javascript

              Whoops - I was not careful enough in looking at this (I was happy just to
              get a script that woked as the user typed). This adds the comma from left
              to right, so if you enter 12345 - you get 123,45. I think using the
              function function that will reverse text, then having it add the commas,
              then reversing it back might fix the issue . . .

              "McKirahan" <News@McKirahan .com> wrote in message
              news:8-WdnQJu9d1dzqrfR Vn-2g@comcast.com. ..[color=blue]
              > "Russell Campbell" <nospam@byteme. com> wrote in message
              > news:wNHZd.4629 $qW.2822@newsre ad3.news.atl.ea rthlink.net...[color=green]
              >> Really? That would be neat.
              >>
              >> After seeing your response I wondered if you're the one to ask this:[/color]
              > where[color=green]
              >> can I find a JavaScript to put commas in a number as it's type into an[/color]
              > HTML[color=green]
              >> textbox? I searched the web for such a script and I find a bunch that[/color]
              > work[color=green]
              >> (I guess) if you want the user to enter the value, then click a button to
              >> format the entry. But that's a lame user interface. I need this to[/color]
              > happen[color=green]
              >> as they type. I tried to modify a few, but I'm still new to JavaScript,[/color]
              > so[color=green]
              >> I didn't have much success. Do you know of such a script?
              >>
              >> Thanks,
              >>
              >> Russell Campbell[/color]
              >
              >
              > Will this help?
              >
              > <html>
              > <head>
              > <title>commas.h tm</title>
              > <script type="text/javascript">
              > function commas(that) {
              > var temp = "";
              > var what = that.value.repl ace(/,/g,"");
              > if (what.length == 0) return;
              > for (i=0; i<what.length; i++) {
              > if (i > 0 && i % 3 == 0) temp += ",";
              > temp += what.charAt(i);
              > }
              > that.value = temp;
              > }
              > </script>
              > </head>
              > <body>
              > <form>
              > <input type="text" name="numb"
              > style="text-align:right"
              > onkeyup="commas (this)">
              > <input type="reset" value="Clear">
              > </form>
              > </body>
              > </html>
              >
              > Of course, JavaScript has to be enabled.
              >
              >[/color]


              Comment

              • McKirahan

                #8
                Re: grid javascript

                "Russell Campbell" <nospam@byteme. com> wrote in message
                news:F1KZd.4724 $qW.3985@newsre ad3.news.atl.ea rthlink.net...[color=blue]
                > Whoops - I was not careful enough in looking at this (I was happy just to
                > get a script that woked as the user typed). This adds the comma from left
                > to right, so if you enter 12345 - you get 123,45. I think using the
                > function function that will reverse text, then having it add the commas,
                > then reversing it back might fix the issue . . .[/color]

                [snip]

                Very poor quality control on my part -- sorry.

                Try this though I may refine it:

                <html>
                <head>
                <title>commas.h tm</title>
                <script type="text/javascript">
                function commas(that) {
                var j = 0;
                var temp = "";
                var what = that.value.repl ace(/,/g,"");
                if (what.length < 4) return;
                for (i=what.length; i>-1; i--) {
                temp = what.charAt(i) + temp;
                if (i > 0 && j == 3) {
                temp = "," + temp;
                j = 0;
                }
                j++;
                }
                that.value = temp;
                }
                </script>
                </head>
                <body>
                <form>
                <input type="text" name="numb"
                style="text-align:right"
                onkeyup="commas (this)">
                <input type="reset" value="Clear">
                </form>
                </body>
                </html>


                Comment

                • Russell Campbell

                  #9
                  Re: grid javascript

                  That works great for the commas. Thanks. It still has the problem with a
                  decimal place, but that's of no concern to me in this particular situation.
                  Try entering 123456.00 and you'll see what I'm talking about.

                  But it's always something, isn't it? I noticed that this seems to kill the
                  "select on entry" feature of the textbox. You know, where you tab to the
                  textbox and its contents are highlighted so that the first thing you type
                  replaces the highlighted text. The textboxes without this script still work
                  that way, but for the ones with the script the text highlights briefly and
                  then immediately goes away. This does not prevent the script from working,
                  but forces the user to stop and manually highlight the text. Kind of
                  strange . . . you wouldn't think a script associated with onKeyUp would
                  exhibit such behavior.

                  Thanks for the help! I must say I'm none too fond of JavaScript. Too
                  cryptic for my taste and the case sensitivity drives me batty. There's no
                  point in it. But, of course, it can help you accomplish some nifty things
                  in a browser.

                  "McKirahan" <News@McKirahan .com> wrote in message
                  news:YeqdnZy7GI h17qrfRVn-uw@comcast.com. ..[color=blue]
                  > "Russell Campbell" <nospam@byteme. com> wrote in message
                  > news:F1KZd.4724 $qW.3985@newsre ad3.news.atl.ea rthlink.net...[color=green]
                  >> Whoops - I was not careful enough in looking at this (I was happy just to
                  >> get a script that woked as the user typed). This adds the comma from
                  >> left
                  >> to right, so if you enter 12345 - you get 123,45. I think using the
                  >> function function that will reverse text, then having it add the commas,
                  >> then reversing it back might fix the issue . . .[/color]
                  >
                  > [snip]
                  >
                  > Very poor quality control on my part -- sorry.
                  >
                  > Try this though I may refine it:
                  >
                  > <html>
                  > <head>
                  > <title>commas.h tm</title>
                  > <script type="text/javascript">
                  > function commas(that) {
                  > var j = 0;
                  > var temp = "";
                  > var what = that.value.repl ace(/,/g,"");
                  > if (what.length < 4) return;
                  > for (i=what.length; i>-1; i--) {
                  > temp = what.charAt(i) + temp;
                  > if (i > 0 && j == 3) {
                  > temp = "," + temp;
                  > j = 0;
                  > }
                  > j++;
                  > }
                  > that.value = temp;
                  > }
                  > </script>
                  > </head>
                  > <body>
                  > <form>
                  > <input type="text" name="numb"
                  > style="text-align:right"
                  > onkeyup="commas (this)">
                  > <input type="reset" value="Clear">
                  > </form>
                  > </body>
                  > </html>
                  >
                  >[/color]


                  Comment

                  • Russell Campbell

                    #10
                    Re: grid javascript

                    Just another bit of info. To highlight the text, I noticed CTRL-A
                    highlights it for a moment then it clears. A triple-click works and and
                    Shift-End works (if done immediately after entering the field). I'm
                    wondering if the script should check for a key code representing a number
                    and ignore anything that's not a number.

                    "McKirahan" <News@McKirahan .com> wrote in message
                    news:YeqdnZy7GI h17qrfRVn-uw@comcast.com. ..[color=blue]
                    > "Russell Campbell" <nospam@byteme. com> wrote in message
                    > news:F1KZd.4724 $qW.3985@newsre ad3.news.atl.ea rthlink.net...[color=green]
                    >> Whoops - I was not careful enough in looking at this (I was happy just to
                    >> get a script that woked as the user typed). This adds the comma from
                    >> left
                    >> to right, so if you enter 12345 - you get 123,45. I think using the
                    >> function function that will reverse text, then having it add the commas,
                    >> then reversing it back might fix the issue . . .[/color]
                    >
                    > [snip]
                    >
                    > Very poor quality control on my part -- sorry.
                    >
                    > Try this though I may refine it:
                    >
                    > <html>
                    > <head>
                    > <title>commas.h tm</title>
                    > <script type="text/javascript">
                    > function commas(that) {
                    > var j = 0;
                    > var temp = "";
                    > var what = that.value.repl ace(/,/g,"");
                    > if (what.length < 4) return;
                    > for (i=what.length; i>-1; i--) {
                    > temp = what.charAt(i) + temp;
                    > if (i > 0 && j == 3) {
                    > temp = "," + temp;
                    > j = 0;
                    > }
                    > j++;
                    > }
                    > that.value = temp;
                    > }
                    > </script>
                    > </head>
                    > <body>
                    > <form>
                    > <input type="text" name="numb"
                    > style="text-align:right"
                    > onkeyup="commas (this)">
                    > <input type="reset" value="Clear">
                    > </form>
                    > </body>
                    > </html>
                    >
                    >[/color]


                    Comment

                    • Russell Campbell

                      #11
                      Re: grid javascript

                      Yep, a change to ignore anything but numbers helped me out. My version:

                      function FormatNumberWit hCommas(toTextb ox)
                      {
                      if (event.keyCode >= 96 && event.keyCode <= 105)
                      {
                      var j = 0;
                      var temp = "";
                      var what = toTextbox.value .replace(/,/g,"");
                      if (what.length < 4) return;
                      for (i=what.length; i>-1; i--)
                      {
                      temp = what.charAt(i) + temp;
                      if (i > 0 && j == 3)
                      {
                      temp = "," + temp;
                      j = 0;
                      }
                      j++;
                      }
                      toTextbox.value = temp;
                      }
                      }


                      Thanks for all your help. I really appreciate it.

                      "McKirahan" <News@McKirahan .com> wrote in message
                      news:YeqdnZy7GI h17qrfRVn-uw@comcast.com. ..[color=blue]
                      > "Russell Campbell" <nospam@byteme. com> wrote in message
                      > news:F1KZd.4724 $qW.3985@newsre ad3.news.atl.ea rthlink.net...[color=green]
                      >> Whoops - I was not careful enough in looking at this (I was happy just to
                      >> get a script that woked as the user typed). This adds the comma from
                      >> left
                      >> to right, so if you enter 12345 - you get 123,45. I think using the
                      >> function function that will reverse text, then having it add the commas,
                      >> then reversing it back might fix the issue . . .[/color]
                      >
                      > [snip]
                      >
                      > Very poor quality control on my part -- sorry.
                      >
                      > Try this though I may refine it:
                      >
                      > <html>
                      > <head>
                      > <title>commas.h tm</title>
                      > <script type="text/javascript">
                      > function commas(that) {
                      > var j = 0;
                      > var temp = "";
                      > var what = that.value.repl ace(/,/g,"");
                      > if (what.length < 4) return;
                      > for (i=what.length; i>-1; i--) {
                      > temp = what.charAt(i) + temp;
                      > if (i > 0 && j == 3) {
                      > temp = "," + temp;
                      > j = 0;
                      > }
                      > j++;
                      > }
                      > that.value = temp;
                      > }
                      > </script>
                      > </head>
                      > <body>
                      > <form>
                      > <input type="text" name="numb"
                      > style="text-align:right"
                      > onkeyup="commas (this)">
                      > <input type="reset" value="Clear">
                      > </form>
                      > </body>
                      > </html>
                      >
                      >[/color]


                      Comment

                      • RobG

                        #12
                        Re: grid javascript

                        Russell Campbell wrote:[color=blue]
                        > Yep, a change to ignore anything but numbers helped me out. My version:
                        >
                        > function FormatNumberWit hCommas(toTextb ox)
                        > {
                        > if (event.keyCode >= 96 && event.keyCode <= 105)
                        > {
                        > var j = 0;
                        > var temp = "";
                        > var what = toTextbox.value .replace(/,/g,"");
                        > if (what.length < 4) return;
                        > for (i=what.length; i>-1; i--)
                        > {
                        > temp = what.charAt(i) + temp;
                        > if (i > 0 && j == 3)
                        > {
                        > temp = "," + temp;
                        > j = 0;
                        > }
                        > j++;
                        > }
                        > toTextbox.value = temp;
                        > }
                        > }
                        >[/color]

                        Or to harness RegExp and not sniff keycodes you could try:

                        function FormatNumberWit hCommas(t) {
                        var n = t.value.replace (/\D/g,'').split('') ;
                        var j = n.length;
                        var z = n[0];
                        if ( j < 4 ) return;
                        while (--j) {
                        ( j%3 )? z += ',' + n[j] : z += n[j];
                        }
                        t.value = z;
                        }


                        Simply removes any non-digit input and works in IE & Firefox.
                        One further optimisation would be to remove leading zeros by
                        modifying the RegExp.

                        Not completely reliable, but OK for some uses I guess.


                        --
                        Rob

                        Comment

                        • RobG

                          #13
                          Re: grid javascript

                          RobG wrote:
                          [...][color=blue]
                          >
                          > Or to harness RegExp and not sniff keycodes you could try:
                          >
                          > function FormatNumberWit hCommas(t) {
                          > var n = t.value.replace (/\D/g,'').split('') ;
                          > var j = n.length;
                          > var z = n[0];
                          > if ( j < 4 ) return;
                          > while (--j) {
                          > ( j%3 )? z += ',' + n[j] : z += n[j];
                          > }
                          > t.value = z;
                          > }
                          >[/color]

                          Ugghh, sorry, meant to save that as draft, didn't realise I'd
                          posted it. Anyway, here is the corrected script (also tested in
                          Safari now too):


                          function FormatNumberWit hCommas(t) {
                          var n = t.value.replace (/\D/g,'').split('') ;
                          var j = n.length;
                          if ( j < 4 ) {t.value = n.join(''); return;}
                          var i = 0;
                          t.value = n[0];
                          while (--j) {
                          ( j%3 == 0 )? t.value += ','+n[++i] : t.value += n[++i];
                          }
                          }


                          --
                          Rob

                          Comment

                          • RobB

                            #14
                            Re: grid javascript

                            Russell Campbell wrote:[color=blue]
                            > I got another version of the function that handles decimals before[/color]
                            you[color=blue]
                            > submitted this one (see other responses), so I switched to that one.
                            > However, I notice now that it (and perhaps yours) does not handle
                            > backspacing properly. For instance, if I enter 11002, I get 11,002 -[/color]
                            [color=blue]
                            > however if I backspace, I end up with 11,00
                            >
                            > It's getting harder for me to follow the version I'm using due to the[/color]
                            heavy[color=blue]
                            > use of regular expressions, so I'm not sure how to handle the[/color]
                            backspace[color=blue]
                            > issue . . .
                            >
                            > Thanks for your continued input.
                            >
                            > "McKirahan" <News@McKirahan .com> wrote in message
                            > news:V8Sdna1SvO mFoaXfRVn-iA@comcast.com. ..[color=green]
                            > > "Russell Campbell" <nospam@byteme. com> wrote in message
                            > > news:xtLZd.5304 $qf2.2341@newsr ead2.news.atl.e arthlink.net...[color=darkred]
                            > >> That works great for the commas. Thanks. It still has the[/color][/color][/color]
                            problem with[color=blue][color=green][color=darkred]
                            > >> a
                            > >> decimal place, but that's of no concern to me in this particular[/color]
                            > > situation.[color=darkred]
                            > >> Try entering 123456.00 and you'll see what I'm talking about.[/color]
                            > >
                            > > Just add the following as the function's first line:
                            > >
                            > > if (that.value.ind exOf(".") >= 0) return;
                            > >
                            > >[/color][/color]

                            Let them eat commas. #:~o

                            That 'slamming caret' always seems to be an issue. Caret control is
                            problemmatic cross-browser so it's probably a matter of how much users
                            will (or should) tolerate.

                            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                            "http://www.w3.org/TR/html4/strict.dtd">
                            <html>
                            <head>
                            <title>untitled </title>
                            <style type="text/css">

                            input {
                            display: block;
                            width: 70%;
                            padding: 3px;
                            margin: 222px auto;
                            font: bold 24px monospace;
                            text-align: center;
                            border: 3px #fff inset;
                            background: ghostwhite;
                            }

                            </style>
                            <script type="text/javascript">

                            //---------------------------------------------//
                            String.prototyp e.reverse = function()
                            {
                            return this.split(''). reverse().join( '');
                            }
                            String.prototyp e.addCommas = function()
                            {
                            var temp = this.reverse();
                            temp = temp.replace(/(\d{3})(?=\d)/g, '$1,');
                            return temp.reverse();
                            }
                            //---------------------------------------------//

                            function filter(str)
                            {
                            return str.replace(/(^0+|\D)/g, '');
                            }

                            function format(ipt)
                            {
                            if (ipt.value.leng th != ipt.prev_value. length)
                            {
                            var m, re = /\.(.*)$/, cents = '';
                            if (m = ipt.value.match (re))
                            {
                            cents += '.'
                            if (!/^$/.test(m[1]))
                            cents += m[1].replace(/\D/g, '').substring(0 , 2);
                            ipt.value = ipt.value.repla ce(re, '');
                            }
                            ipt.value = filter(ipt.valu e).addCommas() + cents;
                            }
                            }

                            function addZeros(ipt)
                            {
                            if (/\.\d*$/.test(ipt.value ))
                            ipt.value += '00';
                            else ipt.value += '.00';
                            ipt.value = ipt.value.repla ce(/(\.\d{2}).+$/, '$1');
                            }

                            window.onload = function()
                            {
                            with (document.forms[0].elements[0])
                            {
                            value = '';
                            focus();
                            }
                            }

                            </script>
                            </head>
                            <body>
                            <form>
                            <input type="text" value=""
                            onkeydown="this .prev_value=thi s.value"
                            onkeyup="format (this)"
                            onblur="addZero s(this)" />
                            </form>
                            </body>
                            </html>

                            Comment

                            • Russell Campbell

                              #15
                              Re: grid javascript

                              You could look at it that way or someone could look at your idea and say
                              that you're willing to take the poor interface that is the Internet and not
                              try to improve it . . .


                              "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
                              news:4MFyPrAHCF OCFwVS@merlyn.d emon.co.uk...[color=blue]
                              > JRS: In article <8-WdnQJu9d1dzqrfR Vn-2g@comcast.com> , dated Tue, 15 Mar
                              > 2005 15:29:38, seen in news:comp.lang. javascript, McKirahan
                              > <News@McKirahan .com> posted :[color=green]
                              >>
                              >>
                              >>Will this help?[/color]
                              >
                              > If one types 123456789 and has 123,456,789 your code does not allow one
                              > to cursor-left and delete the 5.
                              >
                              > Meddling with the user interface is a bad idea.
                              >
                              > If the user wants to see commas, let him type them.
                              > If the application needs commas, let it add them to the number once
                              > completed.
                              >
                              > --
                              > © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00
                              > MIME. ©
                              > Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links,
                              > acronyms
                              > PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see
                              > 00index.htm
                              > Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm
                              > etc.[/color]


                              Comment

                              Working...