1

I want to make a search filter wherein I wanted to search for the status of an item. The status from my DB are int so I made and equivalence of each index.

To explain more, Here is my codes.

MVC Controller

public JsonResult GetStatusList()
    { 
        return Json(new string[] {
            ""
            ,"New"
            ,"Processing"
            ,"PR Approved"
            ,"Qouting"
            ,"Qouting Approved"
            ,"PO Processing"
            ,"Closed"
            ,"Cancelled"
            ,"Rejected"
            ,"PO Issued"
            ,"On Delivery"
            ,"Received"
            ,"AP Posting"
            ,"Payment"
            ,"Sourcing"
            ,"Re-Processing"
        },JsonRequestBehavior.AllowGet);
    }

Here's my MVC View

 <tr data-ng-repeat="model in models  | orderBy: sorting:reverse | filter : filter ">

                    <td>{{jsonDatetotext(model.RequestDate) | date:'MM/dd/yyyy'}}</td>
                    <td>
                        <a href="#" data-toggle="modal" data-target="#basicModalContent" data-ng-click="getSelectedPR(model)">{{model.RequestID}}
                        </a>
                    </td>
                    <td>{{model.PARNumber }}</td>
                    <td>{{model.ProgramName }}</td>
                    <td>{{model.FullName }}</td>
                    <td>{{model.DepartmentName | uppercase}}</td>
                    <td>{{model.PONo}}</td>
                    **<td>{{StatusList[model.StatusID] | uppercase}}</td>**
                    <td class="totalAmount"><span class="pull-right">{{model.TotalAmount | number:2}}</span>
                    </td>
                    <td>{{model.InboxLearUID | lowercase}}</td>
                </tr>

where I wanted to include the status for search filters. The status can only be search by its ID.

Here is my angular

 scope.getStatus = http.get('GetStatusList').success(function (status) {
            scope.StatusList = status;
        });

I wanted the status itself will be searched not just its ID.

1
  • I don't see a filter here? Commented Apr 22, 2015 at 4:27

1 Answer 1

1

Try to add this on your angular. I suggest you use checkbox for your project.

    scope.array_ = angular.copy(scope.array);
        scope.getStatus = http.get('GetStatusList').success(function (status) {
            scope.StatusList = status;

        });


        PRApp.directive("checkboxGroup", function () {
            return {
                restrict: "A",
                link: function (scope, elem, attrs) {
                    // Determine initial checked boxes
                    if (scope.array.indexOf(scope.item.id) !== -1) {
                        elem[0].checked = true;
                    }

                    // Update array on click
                    elem.bind('click', function () {
                        var index = scope.array.indexOf(scope.item.id);
                        // Add if checked
                        if (elem[0].checked) {
                            if (index === -1) scope.array.push(scope.item.id);
                        }
                            // Remove if unchecked
                        else {
                            if (index !== -1) scope.array.splice(index, 1);
                        }
                        // Sort and update DOM display
                        scope.$apply(scope.array.sort(function (a, b) {
                            return a - b
                        }));
                    });
                }
            }
        });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.