Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I have a listview that has currently all the records. But as I want to filter out the listview, I am not being able to show only the filtered datas. Please help me asap.




JavaScript
<div>
    @(Html.Kendo().ListView((IEnumerable<Employee>
        )Model)
        .Name("employeeListView")
        .TagName("div")
        .ClientTemplateId("templateEmployeeListView")
       .DataSource(dataSource => dataSource
                              .PageSize(21).ServerOperation(false)
                              .Read(read => read.Action("GetEmployeeList", "Employee")))

        .Pageable(pageable => pageable.Refresh(false))
        )
</div>

<script type="text/x-kendo-tmpl" id="templateEmployeeListView">
    <div class="employee">
            #:EmployeeName# <br />
            #:CompanyName# <br />
    </div>

</script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#btnSearch").click(function () {
            $.ajax({
                url: "GetEmployeeList",
                type: 'GET',
                contentType: 'application/json',
                data: { EmployeeSearch: $("#txtSearch").val() },
                success: function () {
                    refreshData();
                }
            });

        });
    });

    function refreshData() {
        $("#employeeListView").data("kendoListView").refresh();
    };
</script>


What I have tried:

HTML
<div>
        @(Html.Kendo().ListView((IEnumerable<employee>
            )Model)
            .Name("employeeListView")
            .TagName("div")
            .ClientTemplateId("templateEmployeeListView")
           .DataSource(dataSource => dataSource
                                  .PageSize(21).ServerOperation(false)
                                  .Read(read => read.Action("GetEmployeeList", "Employee")))

            .Pageable(pageable => pageable.Refresh(false))
            )
    </employee></div>
    
    <script type="text/x-kendo-tmpl" id="templateEmployeeListView">
        <div class="employee">
                #:EmployeeName# <br />              
                #:CompanyName# <br />              
        </div>

    </script>
   
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnSearch").click(function () {
                $.ajax({
                    url: "GetEmployeeList",
                    type: 'GET',
                    contentType: 'application/json',
                    data: { EmployeeSearch: $("#txtSearch").val() },
                    success: function () {
                        refreshData();
                    }
                });
              
            });
        });

        function refreshData() {
            $("#employeeListView").data("kendoListView").refresh();           
        };
    </script> 
Posted
Updated 10-May-16 5:18am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900