Click here to Skip to main content
15,348,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've been using angularjs and typescript and i'm unable to filter table records depending on the search word. it works for only one column.

What I have tried:

this is my view where you can input the search word

<input class="form-control" type="text" id="search" placeholder="" ng-model="Text" aria-controls="able_col_reorder">

 <table class="table table-bordered" ng-show="!faqList.IsNull" @*id="datatable_col_reorder"*@>

this is the table where i want to filter records from both answer and question
                                                <th style="width: 10%"></th>
                                                <th style="width: 40%">Question</th>
                                                <th style="width:10%">Created By</th>
                                                <th style="width: 10%">Posted Date</th>

                                            <tr class="ng-cloak" ng-repeat-start="item in faqList | filter: {Question:Text} "  ng-hide="(item.IsActive == false) && Checked" ng-cloak>
                                                    <a class="panel-heading" role="tab"
                                                       id="headingOne" data-toggle="collapse"
                                                       data-parent="#accordion" ng-href="#{{item.Id}}"
                                                       aria-expanded="true" aria-controls="test_div">
                                                <td><a href="@Url.Action("index", "Create")?Id={{item.Id}}">{{item.Question}}</a></td>
                                                <td>{{item.PostedDate | date :'MMM dd, yy'}}</td>

                                            <tr ng-repeat-end>
                                                <td colspan="10">
                                                    <div id="{{item.Id}}" class="panel-collapse collapse" role="tabpanel">
                                                        <table class="table table-bordered">
                                                                <tr class="ng-cloak" ng-cloak>
                                                                    <td><div ng-bind-html="item.FaqAnswer"></div></td>

Updated 25-Oct-18 20:31pm
sajeetharan 26-Oct-18 1:05am
because you are filtering only the Question column
Member 13958707 26-Oct-18 1:19am
yes but i want to know a way to filter the table with both question and answer

1 solution

If you want to filter multiple fields you need to create a custom filter with your logic.

You can follow the link Filtering by Multiple Specific Model Properties in AngularJS (in OR relationship) - Stack Overflow[^]
Member 13958707 26-Oct-18 2:42am
Thanks. I'll see to it
Member 13958707 26-Oct-18 3:49am
It worked. Thanks
sajeetharan 26-Oct-18 5:25am
can you mark it as solution

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