asp.net mvc - How to get a webgrid selected row values of using jquery -
i have webgrid in have 3 columns want catch columns of row , display on alert message example row has 3 columns teamname,description , usercount, when user click on of column user must have 3 details values on alert message. how can have no idea.please help. here view 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>
to values of 3 columns in row, can use following (note i'm not familiar html generated webgrid selectors may need adjusted)
$('.details').click(function() { var row = $(this).closest('tr'); // table row var links = row.find('a'); // 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 required });
Comments
Post a Comment