本文介绍了如何使用jquery获取datagrid的rowindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 其实我想在右键单击datagrid单元格时显示上下文菜单。我的contextmenu正在显示,但是我想获得user.i点击的rowindex的行数据,在datagrid.i中有一个隐藏字段绑定想要获取所选rowindex的hiddenfield值。 $(document).ready(function(){ try { $( #myMenu)。hide(); $( table [id $ ='Grd_Stock']> tbody> tr)。bind( contextmenu,function(e){ $( #myMenu)。hide(); e.preventDefault(); // 它显示所选行的第一个单元格的文本 rowid = $( this ).children(' :first-child')。text(); //显示未定义 var hv = $(' #hd_lead_code')。attr( value); alert(hv); }); hd_lead_code是我隐藏字段的id #myMenu是我的上下文菜单: b $ b < div id = myMenu1 class = contextMenu > < table style = width:100%; > < tr><tdönclick= fnView();>查看产品< / td > < / tr > < tr><tdönclick= fnDelete();>删除产品< / td > < / tr > < tr>< td>团队成员< / td > < / tr > < tr>< td>< asp:DropDownList ID = ddlmembers runat = server宽度= 110px > < / td > < / tr > < tr> < td>< asp:Button ID = btnassign runat = server Width = 100px Text = 分配 onclick = btnassign_Click /> < / td > < / tr > < / 表格 > < / div > 隐藏字段的Html代码: < asp:TemplateField HeaderText = Cust name SortExpression = lead_name > < ItemTemplate > < asp:LinkButton ID = lbtn_name 宽度 = 200px CssClass = grdlinkbtn runat = server OnClick = lbtn_name_click 文字 =' <% #Eval( lead_name)%> ' CausesValidation = false > < / asp:LinkButton > < asp:HiddenField ID = hd_lead_code 值 =' <% #Eval( lead_code)%> ' runat = server / > < / ItemTemplate > < ItemStyle 宽度 = 200px / > ; < HeaderStyle 字体粗体 = true / > < / asp:TemplateField > 解决方案 (document).ready(function(){ 尝试 { ( #myMenu)。hide(); ( table [id Hi,Actually i want to show contextmenu on right click of datagrid cell. my contextmenu is showing but i want to get rowindex of row which is clicked by user.i have a hidden field bind in datagrid.i want to get value of hiddenfield of selected rowindex.$(document).ready(function () { try { $("#myMenu").hide(); $("table[id$='Grd_Stock'] > tbody > tr").bind("contextmenu", function (e) { $("#myMenu").hide(); e.preventDefault();//it shows text of first cell of selected row rowid = $(this).children(':first-child').text();//it shows undefinedvar hv = $('#hd_lead_code').attr("value"); alert(hv);});hd_lead_code is id of my hidden field#myMenu is my context menu like this:<div id="myMenu1" class="contextMenu"> <table style="width:100%;"> <tr><td önclick="fnView();">View Product</td></tr> <tr><td önclick="fnDelete();">Delete Product</td></tr> <tr><td>Team Members</td></tr> <tr><td><asp:DropDownList ID="ddlmembers" runat="server" Width="110px"></td></tr> <tr><td><asp:Button ID="btnassign" runat="server" Width="100px" Text="Assign" onclick="btnassign_Click" /></td></tr> </table> </div>Html code of hidden field:<asp:TemplateField HeaderText="Cust Name" SortExpression="lead_name"> <ItemTemplate> <asp:LinkButton ID="lbtn_name" Width="200px" CssClass="grdlinkbtn" runat="server" OnClick="lbtn_name_click" Text='<%#Eval("lead_name") %>' CausesValidation="false" ></asp:LinkButton> <asp:HiddenField ID="hd_lead_code" Value='<%#Eval("lead_code") %>' runat="server" /> </ItemTemplate> <ItemStyle Width="200px" /> <HeaderStyle Font-Bold="true" /> </asp:TemplateField> 解决方案 (document).ready(function () { try {("#myMenu").hide();("table[id 这篇关于如何使用jquery获取datagrid的rowindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-31 11:25