filter table asp.net mvc [closed]

0

I need to filter a table, which is in a partial view, depending on the parameter entered in a field, which is passed to the controller via ajax. How do I reload the table with the filter applied?

Part of the index where this my partial

<div class="row" id="partial">
   @{Html.RenderPartial("Partial_table", Model);}
</div>

Partial view, where the table is loaded

@model IEnumerable<OAP.Web.MVC.Corp.Models.CorpCRM>


<div style="overflow: auto; height: 700px">
<table id="tbEstatica" class="myTable">

    <tr class="myTable">
        <th class="myTable">Data</th>
        <th class="myTable">Matricula</th>
        <th class="myTable">Produto</th>
        <th class="myTable">Contrato</th>
        <th class="myTable">Penumber</th>
        <th class="myTable">Nome Cliente</th>
        <th class="myTable">Valor</th>
        <th class="myTable">Agencia / Conta</th>
    </tr>
    <tbody>
        @{

            foreach (var item in Model)
            {

                <tr style="height: 50px" class="myTable">
                    <td class="myTable">@item.Dt_Contab</td>
                    <td class="myTable">@item.Matricula</td>
                    <td class="myTable">@item.Produto</td>
                    <td class="myTable">@item.Contrato</td>
                    <td class="myTable">@item.Penumber</td>
                    <td class="myTable">@item.Nome_Cliente</td>
                    <td class="myTable">@item.Valor</td>
                    <td class="myTable">@item.Agencia_Conta</td>
                </tr>
            }

        }
    </tbody>
</table>

Ajax that passes the field parameter;

<script>
function Buscar() {


     $.ajax({
            url: '@Url.Content("~/Home/RetornaCorp")',
            type: 'POST',
            data:
            {
                produto: $("#Produto").val()

            },
            succes: function (data) {
                $("#partial").html(data);
            }
     });



}

Controller that receives the Ajax parameter

 public ActionResult RetornaCorp(int Produto)
    {
        CorpDAO dao = new CorpDAO();
        listaCRM = dao.ListarCorp(Produto);

        return PartialView("Partial_table", listaCRM);
    }
    
asked by anonymous 31.10.2016 / 17:01

1 answer

2

Putting in response to help anyone who has the same problem. (or someone who is too lazy to read comments)

The error happens because of a typo in the success function of $.ajax :

function Buscar() {
     $.ajax({
            url: '@Url.Content("~/Home/RetornaCorp")',
            type: 'POST',
            data:
            {
                produto: $("#Produto").val()
            },
            success: function (data) { //Coreção aqui, adicionando um "S"
                $("#partial").html(data);
            }
     });
}
    
31.10.2016 / 17:44