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 able to understand properly as I am very much new to this Technology.
Can some body help me on this.
Thanks in advance
Murali Krishna
Loading
Jaganathan BantheswaranPosted Dec 14, 2013, 12:33 AM
See the comments added there. Let me know if you have doubts.
Murali krishna AndePosted Dec 16, 2013, 7:56 AM
Murali krishna AndePosted Dec 13, 2013, 9:24 PM
Thanks for the reply,
Here is my client side code binding the table using Knockout
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);
});
Can you plz help on this. How can I filter the users based on the value of "IsApproved" ?
Thank you,
Murali Krishna.
Jaganathan BantheswaranPosted Dec 13, 2013, 1:25 PM
You have to filter the ObservableArray based on approved/rejected state.
I may help you if you upload sample project.
Meantime have a look here
http://jsfiddle.net/Jaganathan/W7mJ3/2/