簡體   English   中英

在jQuery中上下文菜單選擇的gridview中查找行的值

[英]Find value of row in gridview selected by context menu over it in jQuery

我將GridView綁定到DataTable值。 我使用jQuery編寫了上下文菜單。 我的問題是如何讀取右鍵單擊上下文菜單的行的內容。

示例-為了找到網格視圖中的行數,我使用了$("#<%=gridview1. ClientID%> tr").length ,效果很好。

當我只有網格視圖ID(GridView1)時,如何讀取網格視圖的任何單元格或行?

Gridview1.datasource=dt
Gridview1.databind ()

jQuery的

$('#grid').bind ("contextmenu",function       (e){
e.preventDefault ();
......
var $v=$("#<%=gridview1. ClientID%>    tr").length;
$("#divdisplay").html (v)
});

這樣的事情可以解決問題

$('#grid').bind("contextmenu",function(e){
    e.preventDefault ();

    var clickedCellText = $(e.target).text(); // clicked cell text
    var firstCellText = $(e.target).parent().find(':first-child').text(); // first cell text

    //...your code
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM