简体   繁体   English

jQuery数据表显示隐藏

[英]Jquery datatable show hide

I used the datatable script for my table. 我在表中使用了数据表脚本。 Here i have displayed the list of products. 在这里,我显示了产品列表。

Below is the html code for table (For this table i applied datatable script also) 以下是表格的html代码(对于该表格,我也应用了datatable脚本)

            <table width="100%" border="0" cellspacing="0" cellpadding="0" id="example" class="hovertable menuclass display">
        <thead>
        <th width="13%" style="padding-left:3px;">Actions</th>
        <th width="21%">Name</th>
        <th width="12%">col2</th>
        <th width="18%">col3</th>
        <th width="10%">col4</th>
        <th width="7%">col5</th>
        <th width="10%">col6</th>
        <th width="5%" class="last">col7</th>
        </thead>

        <tr  >
        <td align="left" valign="top" style="width:95px;"><img src="images/minus_icon.png" alt="" border="0">  </td>

        <td align="left" valign="top">name1</td>
        <td align="left" valign="top">val</td>
        <td align="left" valign="top">
        value</td>
        <td align="left" valign="top">tetse</td>
        <td align="center" valign="top">test</td>
        <td align="right" valign="top">test</td>
        <td align="center" valign="top" class="last">241</td>
        </tr>   
        <tr  >
        <td align="left" valign="top" style="width:95px;"><img src="images/minus_icon.png" alt="" border="0">  </td>

        <td align="left" valign="top">name2</td>
        <td align="left" valign="top">val</td>
        <td align="left" valign="top">
        value</td>
        <td align="left" valign="top">tetse</td>
        <td align="center" valign="top">test</td>
        <td align="right" valign="top">test</td>
        <td align="center" valign="top" class="last">241</td>
        </tr>         

        </table>

My table row appearance is like this 我的表行外观是这样的

在此处输入图片说明

When i click the '-' image then the row will be hidden and display as 当我单击“-”图像时,该行将被隐藏并显示为

在此处输入图片说明

If i click the undo link then again the corresponding row should be displayed. 如果我单击撤消链接,则应再次显示相应的行。

I used the following code to hide the particular row. 我使用以下代码隐藏了特定的行。

$('.hdrow').live('click', function(){
   $(this).closest('tr').toggle();
}); 

Please refer the fiddle http://jsfiddle.net/2F2E5/2/ 请参阅小提琴http://jsfiddle.net/2F2E5/2/

I dont know how to implement this. 我不知道如何实现这一点。 Please help me. 请帮我。 Thanks 谢谢

Try this on click of minus hide the closest row and keep one td to show hidden messages. 单击减号,尝试此操作隐藏最近的行,并保持一小段时间以显示隐藏的消息。

// Live is depreciated use new `on` method.
$(document).on('click','.minusSign',function(){
    $(this).closest('tr').children().hide();
    $(this).closest('tr').find('td.message').show();
    // Assuming td.message is another table data with 'Product name is now hidden `undo`'
});

and on click of undo hide message td and show the row. 然后点击撤消隐藏消息td并显示该行。

$(document).on('click','td.message a.undu',function(e){
    e.preventDefault();
    $(this).closest('tr').children().show();
    $(this).closest('td.message').hide(); // Here `this` is undo link
});

this should be quick and enough. 这应该足够快捷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM