Click here to Skip to main content
14,935,924 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am developing a web application for the firm using MVC & Knockout. I am very much new to MVC and Knockout. In the admin side I need to display the users who are applied, approved, rejected in the Grid format.

I wrote controller to get AllUsers and I can able to bind all those users to Table. And I want to filter them at the client side using knockout to reduce the round trips to DB. It will boost my application performance.

So, what I need is: how can I check whether the user is Approved or Rejected using Knockout and based on that check I need to bind that data to separate Tables.

I googled about this and I could not able to understand properly as I am very much new to this Technology.

Can some body help me on this.

here is my client side code using Knock out
JavaScript
function UserViewModel(){
    var self=this;
    
    self.UserName = ko.observable("");
    self.ContactNo = ko.observable("");
    self.Email = ko.observable("");
    self.User_ID = ko.observable("");
    self.IsApproved = ko.observable("");

    var ApprovedUsers = {
        UserName: self.UserName,
        ContactNo: self.ContactNo,
        Email: self.Email,
        User_ID: self.User_ID,
        IsApproved: self.IsApproved     
    };

    self.ApprovedUsers = ko.observableArray();

    $.ajax({
          url: "Home/GetAllUsers",
          cache: false,
          type: "JSON",
          contentType: "application/json; charset=utf-8",
          data: {},
          success: function(data){
               self.ApprovedUsers(data);  
          }
    });
}

$(document).ready(function(){
     var viewModel = new UserViewModel();
     ko.applyBindings(viewModel);
});


I can able to bind all the data by using the above code, but it was included all type users (Approved, Applied & Rejected).

How can I check the value of Property "IsApproved" on client side and based on that How can I filter the data using KnockOut?

Thanks in advance
Murali Krishna
Posted
Updated 13-Dec-13 15:13pm
v3

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