Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,

i am confuse here ,
i create a IEnumerable list view of model ,
and on button click on list view table i need all cell value /text

Please help me here

What I have tried:

<div class="Datadiv">
					<div class="sbox pull-right">
						@using (Html.BeginForm("ConvertrWorker", "Perchus", FormMethod.Get))
						{
						}
					</div>

					<table class="tbl1 table-responsive table-hover table-bordered" id="tbl1" style="width:100%">
						<tr style="background-color:palegoldenrod;height:135%" class="data1">
							<td style="width:30%">
								SypplyerName
							
							</td>
							<td>
								Challa No
							</td>
							<td>
								ChallaDate
							
							</td>
							<td>
								TaxAmount
							</td>
							<td>
								Challan Amount
							</td>
							<td>Control</td>
							<td>Control</td>
						</tr>
						@foreach (var item in Model)
						{
							<tr style="background-color:#eff6de">
								<td class="hfr">
									@Html.HiddenFor(modelItem => item.PerTranChallanId, new { @class = "PerTranChallanId" })
									@Html.HiddenFor(modelItem => item.PTranCode, new { @class = "PTranCode" })
								</td>
								<td class="sn1">
									@Html.DisplayFor(modelItem => item.SypplyerName ,new {@class="sn", @id = "SypplyerName" })
								</td>
								<td>
									@Html.DisplayFor(modelItem => item.ChallaNo)
								</td>
								<td>
									@Html.DisplayFor(modelItem => item.ChallaDate)
								</td>
								<td>
									@Html.DisplayFor(modelItem => item.TaxAmount)
								</td>
								<td>
									@Html.DisplayFor(modelItem => item.TotalAmount)
								</td>
								<td>
									@Html.ActionLink("Details", "Showchl1", new { id = item.PerTranChallanId , PTranCode=item.PTranCode }) |
								</td>
								<td class="con">
									<input type="submit" id="convt" name="convt" value="Add To INv No:- @ViewBag.NewINVNo1"  class="convt btn btn-success " />

					
								</td>
								<td class="csl">
									<input type="submit" id="cansel" name="cancel" value="Cancel From INv No:- @ViewBag.NewINVNo1" class="convt btn btn-danger " />
								</td>
							</tr>
						}
					</table>
                              </div>
			</div>


jquery

<script>
		$(document).ready(function () {
			$(document).on('click', 'convt', function () {
				var $supplyer = $(this).closest("tr").find(".sn").val();
				alert($supplyer);
			})

		});
	
	</script>
Posted
Updated 17-Mar-19 1:35am

1 solution

You are setting your 'click' event to the document, you need to associate it with the table. Try soomething like this!

$(document).ready(function () {
  $('.tbl1').on('click', 'convt', function () {
  {
    $(this).closest('tr').find('td').each(function (i) {
          console.log($(this).text());
    });
  });
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900