我有一个webgrid,其中我有3列我想要的是捕获行的所有列并将其显示在警报消息上,例如,一行有3列teamname,description和usercount,当用户单击时任何此列用户必须在警报消息上具有3个详细信息值。我怎么能这样做不知道。请帮忙。 这是我对webgrid的看法。
<div class="table-responsive">
@{
var grid = new WebGrid(source: Model.TeamList.ToList(), canPage: true, rowsPerPage:10);
}
@grid.WebGridSelectAll(
headerStyle: "gridHeader",
tableStyle: "table table-condensed table-striped table-bordered table-hover no-margin",
checkBoxValue: "TeamId",
columns: new[]{
grid.Column("TeamName",format: @<a href="#" class="details" data-id="@item.TeamId" data-dialogmodalbind=".dialog_content3">@item.TeamName</a>,header: Html.CustomText("lblCTTeamName", "Team Name")),
grid.Column("Description",format: @<a href="#" class="details" data-id="@item.TeamId" data-dialogmodalbind=".dialog_content3">@item.Description</a>, header: Html.CustomText("lblDescription", "Description"), canSort: false),
grid.Column("UserCount",format: @<a href="#" class="details" data-id="@item.TeamId" data-dialogmodalbind=".dialog_content3">@item.UserCount</a>, header: Html.CustomText("lblCTUserCount", "# of User(s)"))
}
)
</div>
答案 0 :(得分:2)
要连续获取3列的值,可以使用以下内容(注意我不熟悉WebGrid生成的html,因此可能需要调整选择器)
$('.details').click(function() {
var row = $(this).closest('tr'); // get the table row
var links = row.find('a'); // get the 3 hyperlinks
var teamName = links.eq(0).text();
var description = links.eq(1).text();
var userCount = links.eq(1).text();
alert(teamName + ' ' + description + ' ' userCount); // adjust format as required
});