хочу получить текст заголовка столбца, по которому я щелкаю.Следующее получает данные ячейки из строки и столбца, в которых происходит щелчок:
if ($(this).index() == 3) {
var row2 = $(this).parents("tr:first");
var Col3 = row2.children("td:eq(3)").text();
alert(Col3);
}
Вместо этого мне нужен заголовок столбца.
Спасибо
Вот Gridview
<asp:GridView ID="GV_Tab1"
class= "GV_card"
AutoGenerateColumns="false" HeaderStyle-CssClass="HeaderCss2"
runat="server"
OnSelectedIndexChanged="GV_Scorecard_Tab1_SelectedIndexChanged"
OnRowDataBound="GV_Tab1_RowDataBound"
>
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="Col"
runat="server"
commandargument='<%# Container.DisplayIndex%>'
ItemStyle-Width="54"
ItemStyle-Height="20px"
> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:boundfield datafield="secure 1" headertext="secure 1" ItemStyle-Width="220px" ItemStyle-Height="20px" />
<asp:boundfield datafield="secure 2" headertext="secure 2" ItemStyle-Width="140px" ItemStyle-Height="20px" />
<asp:boundfield datafield="aDays" DataFormatString="{0:n0}" headertext="0-30 Days" visible='true' ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right"/>
<asp:boundfield datafield="bDays" DataFormatString="{0:n0}" headertext="31HorizontalAlign="Right"/>
<asp:boundfield datafield="fDays" DataFormatString="{0:n0}" headertext="151-180 Days" visible='true' ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right"/>
<asp:boundfield datafield="gDays" DataFormatString="{0:n0}" headertext="180+ Days" visible='true' ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right"/>
<asp:boundfield datafield="Total" DataFormatString="{0:n0}" headertext="Grand Total" ItemStyle-Width="65px" ItemStyle-HorizontalAlign="Right"/>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="ColumnRef"
runat="server"
commandargument='<%# Container.DisplayIndex%>'
ItemStyle-Width="54"
ItemStyle-Height="20px"
> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Вот код события: $ (документ) .ready (function () {
if ($("#<%=GV_Tab1.UniqueID%> th") != "Column Title") {
$("#<%=GV_Tab1.UniqueID%> td").click(function() {
Вот разметка HTML:
<div id="GV_Tab1-divid" >
<div>
<table cellspacing="0" rules="all" class="GV_Scorecard" border="1" id="GV_Scorecard_Tab1" style="border-collapse:collapse;">
<tr class="HeaderCss2">
<th scope="col"> </th><th scope="col">secure 1</th><th scope="col">secure 1</th><th scope="col">0-30 Days</th><th scope="col">31-60 Days</th><th scope="col">61-90 Days</th><th scope="col">91-120 Days</th><th scope="col">121-150 Days</th><th scope="col">151-180 Days</th><th scope="col">180+ Days</th><th scope="col">Grand Total</th><th scope="col"> </th>
</tr><tr>
<td onClientClick="alert('Cell 0 Clicked');" style="background-color:#F5DCBE;">
<span id="GV_Tab1_ctl02_Col" ItemStyle-Width="54" ItemStyle-Height="20px" commandargument="0"></span>
</td><td style="background-color:#F5DCBE;height:20px;width:220px;">