Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Obtenga Table HTML Editor por valor en jQuery

En mi aplicación asp.net MVC, hay una tabla que muestra algunos valores del modelo de vista.

Para actualizar los valores, pensé en colocar Id y Qty en una matriz y pasarlos al controlador.

Aquí está mi tabla

 <div class="card-body p-0"> <table id="tblParts" class="table table-striped"> <thead> <tr> <th> Part Number </th> <th> Description </th> <th> Model </th> <th> Order Qty </th> <th></th> </tr> </thead> <tbody> @foreach (var item in Model.OrderBy(i => i.PartNumber)) { <tr> <td style="display:none;"> @Html.DisplayFor(modelItem => item.Id) </td> <td> @Html.DisplayFor(modelItem => item.PartNumber) </td> <td> @Html.DisplayFor(modelItem => item.Description) </td> <td> @Html.DisplayFor(modelItem => item.Model) </td> <td id="Qty"> @Html.EditorFor(modelItem => item.OrderQty) </td> </tr> } </tbody> </table> </div> <div class="card-footer"> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="button" value="Update Order" class="btn btn-success" onclick="UpdateOrder();" /> </div> </div> </div>

Este es el JQuery, aquí obtiene la Id pero no obtiene la Qty en la matriz.

 <script > function UpdateOrder() { const Orders = $("#tblParts tbody tr").filter(function () { const cells = $(this).find("td"); return cells.eq(4).text().trim() != "" }).map(function () { const cells = $(this).find("td"); return { [cells.eq(0).text().trim()]: +cells.eq(4).text() } }).get() console.log(Orders); var newOrders = $.map(Orders, function (element) { var obj = {}; for (var key in element) { obj.Id = key; obj.Quantity = element[key]; } return obj; }); } </script>

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!