English 中文(简体)
利用JQuery对表格内容进行编码
原标题:Sliding the table contents using JQuery
  • 时间:2012-01-15 13:23:15
  •  标签:
  • jquery

我需要一些帮助,把表内容放在一栏(左栏/右栏)上。 因此,假定该表有10个段落,但我可以同时显示4个。 该表还有10栏,一栏可以随时显示。 现在,我需要发展行各业。 感谢任何帮助。

我试图躲藏一行/栏杆,但为了搬走一行,我需要获得第一只看得见的行id和最后可见的行.。 我目前所困的地方。 找到第一个看得见的浏览器/col。 也是最后可见的一行/栏。 这将是有益的。

问题回答

你们不需要通过身份证。 首先是储存与变数相关的一切:制约因素,但更重要的是,目前看得见的行文/栏目——或指数,从而增加/减少流动的行文/栏目。

大致如下:

(function () {
    var $rows = $( .my-row ),
        numberOfRows = $rows.length,
        // assuming there is no colspan magic at work
        numberOfCols = $rows.children().first().length, 

        visibleRows = 4,
        visibleCols = 5,

        firstVisibleRow = 0, // not 1 because Arrays are 0-indexed
        firstVisibleCol = 0,

       moveDown = function () {
           $rows.slice(firstVisibleRow, numberOfRows).hide();
           firstVisibleRow += visibleRows;
           $rows.slice(firstVisibleRow, numberOfRows).show();
       },

       moveRight = function () {
           var newFirstVisibleCol = firstVisibleCol + visibleCols,
               i, len,
               currentRow;

           for (i = 0, len = $rows.length; i < len; i++) {
               currentRow = $rows.eq(i).children(); // TDs of current Row
               currentRow.slice(firstVisibleCol, visibleCols).hide();
               currentRow.slice(newFirstVisibleCol, visibleCols).show();
           }

           firstVisibleCol = newVisibleCol;
       },

       moveUp = function () {
           // ...
       }

       moveLeft = function () {
           // ...
       };


    // initialise the table, hide rows/cols 6 and on
    // bind events
    // etc
    // ...
}());

你们一旦这样做,就不要忘记增加逻辑,以照顾你们的人数。 OfRows/ number 其中 这样一来,你就能够打上桌子的“发展”。


In response to the comment below - since I can t use code tags in comments:

例如,你可以使用

<buttonid="makeitMoveRight">Move 5 cols to the right</button>

然后使用

$("#makeItMoveRight").click(moveRight); // or
$("#makeItMoveRight").bind("click", moveRight) // which essentially do the same

在上文(对外职能)的关闭范围内。 你可能想在职能表述中增加一个额外的参数,如:

// add a parameter for the event passed by jQuery
moveRight = function (event) {
    // ... rest of the function here ...

    // also, add this:
    event.preventDefault();
}

如果你的控制要素是固定的或按纽扣的,则防止出现违约行为(例如,提交周围表格或沿上线/倾斜)。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签