Tuesday, June 18, 2019

Search in Jquery

1. Html

    <div class="col-md-4">
        <div class="row">
            <div class="col-md-12">
                <input type="search" id="id_forms" placeholder="Search" class="col-md-12" />
            </div>
        </div>
        <table class="table" id="tbl_form" width="100%">
            <thead>
                <tr>
                    <th>Srno</th>
                    <th>Forms</th>
                </tr>
            </thead>
            <tbody>
                @for (int i = 0; i < fl.Count; i++)
                {
                    <tr>
                        <td>@(i + 1)<input type="hidden" value="@fl[i].formid"></td>
                        <td>@fl[i].form_name</td>
                    </tr>
                }
            </tbody>
        </table>
    </div>

2. JQuery

<script src="~/scripts/jquery-3.4.1.min.js"></script>
<script>
    $(document).ready(function () {      
        $("#id_forms").on("keyup", function () {
            var value_ = $(this).val().toLowerCase();
            $("#tbl_form tbody tr").filter(function () {
                $(this).toggle($(this).text().toLowerCase().indexOf(value_) > -1)
            })
        })
        
    })
</script>



No comments:

Post a Comment

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)