开发者

how to select complete Column when a cell in that column is selected?

Currently, I am working on Gridview of ASP.net VS2010. In this application 1. I want to select complete column on a selection of 1 single cell in that column. 2. Gridview have 2 groups into it. Each group having same column name. Like

_____________

Unloading     | Loading

_______________

Amount| Item | Amount| Item | | |

If I select Loading-> Amount colum开发者_StackOverflow中文版n, it should select Unloading->Amount and Loading->Amount column as well.

Your any kind of guidance will help.

Thanks, TA


You can use jQuery to accomplish this. Give "ColumnA" a special class and "ColumnB" a special class. When "ColumnA" is clicked, all "ColumnB" cells will be highlighted:

//Wait for the document to load.
$(document).ready(function()
{
    //Add a handler for when anything with class "ColumnA" is clicked.
    $(".ColumnA").click(function()
    {
        //When that happens, add the "Highlighted" class to all elements with the class "ColumnB."
        $(".ColumnB").addClass("Highlighted");
    });
});

Should get you on the right path.


I am able to do it by JQuery. Code snippet is as below.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">

    $(function () {
        var rows = $('#grd tr');
        rows.children().click(function () {
            rows.children().removeClass('Highlighted');
            var index = $(this).prevAll().length;  
     rows.find(':nth-child(' + (index + 1) + ')').addClass('Highlighted');  });
      });

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜