how can i send the checked row to the first at table

how can i send the checked row to the first at table

bubbles25bubbles25 Posts: 4Questions: 3Answers: 0
edited August 22 in Free community support

This code actually works adding row, however when i checked the primary contact it didnt send to the first row instead it send to the last, kindly help me to fix this

  //add row in contact
  $(document).ready(function () {
      var table = $('#lv_Lead_Contact_Information-datatable').DataTable({
          dom: "t"
      });

      //ensure the primary contract is only one
      $(document).on('change', '.primary-contact-checkbox', function () {
          if (this.checked) {
              // Uncheck all other checkboxes
              $('.primary-contact-checkbox').not(this).prop('checked', false);

              // Get the row of the checked checkbox
              var row = $(this).closest('tr');

              // Move the row to the top of the table
              row.fadeOut(function () {
                  table.row(row).remove().draw(false);
                  table.row.add(row[0]).draw(false);
                  row.fadeIn();
              });
          }
      });

      $(document).on('click', '#btnAddContact', function () {
          table.row.add([
              '<input type="checkbox" class="form-check-input primary-contact-checkbox" style="vertical-align: middle; margin-left: 21px;">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="text" class="form-control form-control-borderless">',
              '<input type="checkbox" class="" style="vertical-align: middle; margin-left: 19px;">',
              '<input type="text" class="form-control form-control-borderless">'
          ]).draw();
      });
  });

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    Can you link to a test case showing the issue, per the forum rules please?

    I don't see how the form is being submitted. Are you making an Ajax call, or submitting a regular <form> or something else?

    Allan

Sign In or Register to comment.