Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda