大家好我想使用JQuery获取选定的行数据我能够获取可见字段的数据,但不能隐藏字段。这是我的WebGrid结合MVC5 jquery选择隐藏字段的行数据
@using (Html.BeginForm("DeleteSelected", "Email", FormMethod.Post))
{
WebGrid grid = new WebGrid(Model);
@grid.GetHtml(
tableStyle: "table",
selectedRowStyle: "selected",
headerStyle: "header",
alternatingRowStyle: "alternate",
htmlAttributes: new { id = "checkableGrid" },
columns: grid.Columns
(
grid.Column(
format: @<text> <input class="checkbox-inline" type="checkbox" id="@item.MessageID" value="@item.MessageID" name="ids" /> </text>,
header: ""),
grid.Column("From", "From"),
grid.Column("Subject", "Subject"),
grid.Column("Body",format:@<text> <input type="hidden" id="@item.MessageID" name="IDHidden" value="@item.Body" /></text>),
grid.Column("MailDate", format: @<text> <input type="hidden" id="@item.MessageID" name="IDHidden" value="@item.MailDate" /></text>)
)
)
<span id="validationMessage" />
}
我的JavaScript代码
$('#checkableGrid tr').each(function (i, e) {
$(e).children('tr td:not(:first)').css('cursor', 'pointer');
$("#checkableGrid tr:nth-child(n) td").each(function() {
alert($(this).text());
`});
$(e).children('td:not(:first)').click(function() {
})
})
这样可以有一个人帮助我,我想读与隐藏字段每列数据。
<table class="table" id="checkableGrid">
<thead>
<tr class="header">
<th scope="col"><input type="checkbox" id="cbSelectAll" value=""></th>
<th scope="col">
<a href="/Email/GetMails?sort=From&sortdir=ASC">From</a> </th>
<th scope="col">
<a href="/Email/GetMails?sort=Subject&sortdir=ASC">Subject</a> </th>
<th scope="col" style="display: none;">
<a href="/Email/GetMails?sort=Body&sortdir=ASC">Body</a> </th>
<th scope="col" style="display: none;">
<a href="/Email/GetMails?sort=MailDate&sortdir=ASC">MailDate</a> </th>
</tr>
<tr>
<td> <input class="checkbox-inline" type="checkbox" id="3709" value="3709" name="ids"> </td>
<td style="cursor: pointer;">CouponDunia</td>
<td style="cursor: pointer;">New Year Offers & More: Paytm Upto 222 Cashback, Amazon EOSS Upto70% Off, eBay Top Deals on Electronics & More</td>
<td style="display: none; cursor: pointer;"> <input type="hidden" id="3709" name="IDHidden" value="some text"
<td style="display: none; cursor: pointer;"> <input type="hidden" id="3709" name="IDHidden" value="1/2/2016 1:34:56 AM"></td>
</tr>
</thead></table>
呈现的HTML看起来如何? – Shyju