[ Foro de Javascript ]

Obtención de valor y enviar como parámetro a vista

10-Apr-2019 01:47
Invitado (@lex)
0 Respuestas

Tengo una vista en MVC en la cual estoy intentando enviar un elemento de mi lista con datos al controlador utilizando javascript pero no se la manera de obtener esa lista desde la función java, ni se como mandarla al controlador. La vista es la siguiente:

@model TNCBanrruralMG.Models.Navegacion.TransaccionesPendientesModel

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script type="text/javascript">
   $(document).ready(function () {
       $('.showDetalle').click(function () {
           debugger;
           var valor = document.getElementById(this).value;
           var urls = '@Url.Action("DetallePendientes", "Pendientes",new { @Id_transfer = "param-id"})';
       urls = urls.replace("param-id", valor);
       $.ajax({
           cache: false,
           async: true,
           type: "GET",
           url: urls,
           data: {},
           success: function (response) {
               $('#resultado').html('');
               $('#resultado').html(response);
           }
       });
       $('#Modalview').modal('show');
   });
   $('.showRechazo').click(function () {
       var urls = '@Url.Action("RechazoPendientes", "Pendientes")';
       $.ajax({
           cache: false,
           async: true,
           type: "GET",
           url: urls,
           data: {},
           success: function (response) {
               $('#resultado').html('');
               $('#resultado').html(response);
           }
       });
       $('#Modalview').modal('show');
  });
});
</script>

@{
   if (Model.inicio != true && Model.No_referencia == null)
   {
       <script> swal("", "Usuario no encontrado", "error")</script>
   }

   if (Model.envtransdetalle != null && Model.envtransdetalle.confirma == true)
   {
       <script> swal("Envio de transaccion.", "Los datos hansido enviados correctamente.", "success")</script>
   }
   else
   {
       if (Model.envtransdetalle != null && Model.envtransdetalle.confirma == false)
       {
           <script> swal("Envio de transaccion.", "Ocurrio un error en el envio, intente nuevamente.", "error")</script>
       }
   }
}

<div id="Modalview" class="modal fade in">
   <div class="modal-dialog">
       <div class="modal-content">
           <div class="modal-body">
               <div id="resultado"></div>
           </div>
       </div>
   </div>
</div>

<div style="font-family:Lato;">
   <div class="navbar navbar-default" style="background-color:#0B733F;">
       <div class="navbar-header navbar-left tit1">
           <div style="padding-left:40px; position:absolute;">
               <h3 style="margin-top: 10px;">
                   <img width="40" height="30" src="~/Resources/img/img_pendientes.png"><font color="white"> Transacciones Pendientes</font>
               </h3>
           </div>
           @using (Html.BeginForm("BuscaTrPendiente", "Pendientes", FormMethod.Post, new { id = "frmSubmitbuscaTrPendiente" }))
           {
               <div class="form-group has-feedback col-md-offset-9 col-md-3" style="position:absolute; padding-top:8px; padding-left:0px;">
                   <div style="position:absolute; width:230px;" class="col-md-offset-2">
                       @Html.TextBoxFor(m => m.No_referencia, new { @class = "form-control", @placeholder = "Numero de Referencia", @style = "border-radius:15px; width:230px; background-color:#D6E7DF;" })
                   </div>
                   <div class="col-md-offset-8" style="position:absolute; padding-top:2px; padding-left:10px; width:83px;">
                       <button class="btn-sm btn-success glyphicon glyphicon-search" style="border-radius:15px; width:75px; height:27px; border:none; padding-left:0px; padding-right:0px; background-image:linear-gradient(-180deg, #4D8A6C 0%, #096135 76%, #247951 99%); box-shadow: 0 2px 2px 0 rgba(113,113,113,0.50);">
                       Buscar </button>
                   </div>
               </div>
           }
       </div>
   </div>
   <div style="height:380px; background: #FFFFFF; box-shadow: 0 2px 4px 0 rgba(157,157,157,0.50); border-radius: 10px;">
       <table class="col-md-12" align="center" style="display:table; padding:1px;">
           <thead align="center" style="border-radius:10px;">
               <tr style="background: #F7BF66; font-weight:bold;">
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Oficina</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Monto Total</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Tarifa Envio</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Remitente</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Beneficiario</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Fecha Nacimiento Remitente</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Telefono</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Pais Destino</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Estado Destino</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Moneda Envio</td>
                   <td style="border: 2px solid white; padding-left:5px; padding-right:5px;">Rechazar</td>
               </tr>
           </thead>
           <tbody align="center" class="table table-striped" style="border-radius:10px;">
               @foreach (var item in Model.list)
               {
                   <tr style="color:#0B733F; font-weight:bold;">
                       <td style="border: 2px solid white;">@item.Oficina</td>
                       <td style="border: 2px solid white;">@item.Monto_total</td>
                       <td style="border: 2px solid white;">@item.Tarifa</td>
                       <td style="border: 2px solid white;">@item.Remitente</td>
                       <td style="border: 2px solid white;">@item.Nombre_beneficiario</td>
                       <td style="border: 2px solid white;">@item.Fec_nac_remitente</td>
                       <td style="border: 2px solid white;">@item.Telefono</td>
                       <td style="border: 2px solid white;">@item.Pais_destino</td>
                       <td style="border: 2px solid white;">@item.Estado_destino</td>
                   <td style="border: 2px solid white;">@item.Moneda_envio</td>
                   <td style="border: 2px solid white;">
                       <div></div>
                       <div style="padding-top:1px;">
                           <button id="but" value="@item" class="showDetalle" style="border:none; border-radius:20px; width:30px; height:30px; background-image:url(../../Resources/img/icon_rechazar.png); background-repeat:no-repeat; background-position:center;"></button>
                       </div>
                   </td>
               </tr>
               }
           </tbody>
       </table>
   </div>
   <div class="col-md-12" style="padding-top:30px; padding-left:180px; margin-bottom:20px;">
       <button value="" class="showRechazo col-md-offset-9" style="width:250px; border-radius:15px; color:white; background-image:linear-gradient(-180deg, #4D8A6C 0%, #096135 76%, #247951 99%); box-shadow: 0 2px 2px 0 rgba(113,113,113,0.50);">Rechazadas por MoneyGram</button>
   </div>
</div>




(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)