Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
Get Table HTML Editor for value in jQuery

In my asp.net MVC application, There is a table that shows some values from the view model.

To update values I thought getting Id and Qty to array and pass to the controller.

Here is my Table

    <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>

This is the JQuery, Here it gets the Id But it does not get the Qty to the array.

<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>

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda