SlideShare une entreprise Scribd logo
1  sur  5
Implement Search screen using
knockoutjs, Jquery and asp.net
mvc3
                                  Neeraj Kaushik
                                  This article demonstrates implementation of knockoutjs
                                  observable viewmodel and how to bind viewmodel with
                                  html controls.




              www.dotnetdlr.com


[Type text]                                                                    Page 0
http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net-
mvc3-2/


Here I am trying to explain steps for how to use knockoutjsviewmodel, jqueryajax request in
asp.net mvc3 project.

I am taking practical example to show behaviour. This example will have simple UI screen
with search textbox and button. When click on search button ajax request will go to server
and will call action method of controller class which will return results in json format, then
we will see how json result will bind to viewmodel and html controls.

Following is flow of information across different layers:




Let’s start implementation.

Implementation

Model

Create model class Employee.

class Employee
    {
publicintEmployeeID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string Phone { get; set; }
public string Dept { get; set; }
    }

Controller

        Create Controller class in controller folder i.e. EmployeeController
        Implement Action method “Search” which will search on empname.

publicJsonResult Search(string EmpName)
        {
varemplist = PrepareEmpList();

varsearchedlist= from emp in emplist
whereemp.Name.Contains(EmpName)
selectemp;

returnJson(new { Items = searchedlist});
        }


      1
http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net-
mvc3-2/


private static List PrepareEmpList()
        {
varemplist = new List();
            //create list of employee
for (inti = 0; i< 20; i++)
            {
varemp = new Employee();
emp.EmployeeID = i;
emp.Name = string.Format("Employee-{0}", i);
emp.Address = string.Format("ABC New Delhi- 1{0}", i);
if (i % 2 == 0)
emp.Dept = "IT";
else
emp.Dept = "Admin";

emplist.Add(emp);
            }
returnemplist;
        }

In above code controller has action method “Search” which has code to search on supplied
search condition and send back result in json object.

View

@{
ViewBag.Title = "Employee Search";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
<script src="../Scripts/knockout-2.0.0.js"></script>
}

<h2>
       Employee List</h2>

<div>
Search:<input type="text" data-bind="value:empname" />

<input type="button" id='btnSearch' title="Search" value="Search"/>
</div>

<table style="border-style:solid;border-width:1px">
<thead style="background-color:Gray">
<tr>
<th>
                ID
</th>
<th>
                Name
</th>
<th>
                Address
</th>
<th>
                Phone
</th>

       2
http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net-
mvc3-2/


</tr>
</thead>
<tbody data-bind="foreach: employeemodel.employees">
<tr>
<td data-bind="text: EmployeeID">
</td>
<td data-bind="text: Name">
</td>
</tr>
</tbody>
</table>

<input type="text" data-bind="value:empname" />

this is input text box which is bind to empname property of knockoutjsviewmodel which is
defined in javascript file.

<tbody data-bind="foreach: employeemodel.employees">

This will use for looping in viewmodel’s observable collection.

Note: “data-bind” attribute is used to bind knockoutjsviewmodel.

View Model

Viewmodel is defined in java script file. This viewmodel also has search function which
sends ajax request to “Search” action method on server and receive jsonresult .

Employee.js

varemployeemodel;
$(document).ready(function () {

    //initializing viewmodel
employeemodel = new viewModel();
    //binding for ko
ko.applyBindings(employeemodel);
    //bind event
    $("#btnSearch").click({ handler: employeemodel.search });
    //call search method
    //employeemodel.search();

});

functionviewModel() {
var self = this;
self.employees = ko.observableArray([]);
self.empname = ko.observable('');
self.search = function () {
        $.ajax({
url: "Employee/Search",
data: { EmpName: self.empname },
type: "POST",
success: function (response) {

      3
http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net-
mvc3-2/


                //bind data
self.employees(response.Items);
self.DeptId(response.DeptId);
            }
        });

    }
}

Output




You can find code here.




      4

Contenu connexe

Tendances

Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...solit
 
Redux Thunk - Fu - Fighting with Async
Redux Thunk - Fu - Fighting with AsyncRedux Thunk - Fu - Fighting with Async
Redux Thunk - Fu - Fighting with AsyncArtur Szott
 
Protect from forgery
Protect from forgeryProtect from forgery
Protect from forgeryChad Harmon
 
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)Markus Eisele
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4soelinn
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentArtur Szott
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSAnass90
 
20190627 j hipster-conf- diary of a java dev lost in the .net world
20190627   j hipster-conf- diary of a java dev lost in the .net world20190627   j hipster-conf- diary of a java dev lost in the .net world
20190627 j hipster-conf- diary of a java dev lost in the .net worldDaniel Petisme
 
FormObject For Building Complex Forms. Dmytro Pilugin
FormObject For Building Complex Forms. Dmytro PiluginFormObject For Building Complex Forms. Dmytro Pilugin
FormObject For Building Complex Forms. Dmytro PiluginSphere Consulting Inc
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 

Tendances (19)

Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Redux Thunk - Fu - Fighting with Async
Redux Thunk - Fu - Fighting with AsyncRedux Thunk - Fu - Fighting with Async
Redux Thunk - Fu - Fighting with Async
 
Protect from forgery
Protect from forgeryProtect from forgery
Protect from forgery
 
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4
 
Knockout js
Knockout jsKnockout js
Knockout js
 
React.js 20150828
React.js 20150828React.js 20150828
React.js 20150828
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenment
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
20190627 j hipster-conf- diary of a java dev lost in the .net world
20190627   j hipster-conf- diary of a java dev lost in the .net world20190627   j hipster-conf- diary of a java dev lost in the .net world
20190627 j hipster-conf- diary of a java dev lost in the .net world
 
Human Talks - StencilJS
Human Talks - StencilJSHuman Talks - StencilJS
Human Talks - StencilJS
 
FormObject For Building Complex Forms. Dmytro Pilugin
FormObject For Building Complex Forms. Dmytro PiluginFormObject For Building Complex Forms. Dmytro Pilugin
FormObject For Building Complex Forms. Dmytro Pilugin
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
 

En vedette

Concurrent Collections Object In Dot Net 4
Concurrent Collections Object In Dot Net 4Concurrent Collections Object In Dot Net 4
Concurrent Collections Object In Dot Net 4Neeraj Kaushik
 
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specification
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specificationImplementation of fix messages for fix 5.0 sp2 and fixt1.1 specification
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specificationNeeraj Kaushik
 
Edison learning cms_manual
Edison learning cms_manualEdison learning cms_manual
Edison learning cms_manualJennifer Pricci
 
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide)
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide) Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide)
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide) Jennifer Pricci
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorNeeraj Kaushik
 
Bob burgeronlinepresskit
Bob burgeronlinepresskitBob burgeronlinepresskit
Bob burgeronlinepresskitJennifer Pricci
 
Z100 clearchannelgeneralcapabilities
Z100 clearchannelgeneralcapabilitiesZ100 clearchannelgeneralcapabilities
Z100 clearchannelgeneralcapabilitiesJennifer Pricci
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot NetNeeraj Kaushik
 
New Directions in Project Management
New Directions in Project ManagementNew Directions in Project Management
New Directions in Project Managementguestbb073ee
 
Sell your house-patrick_parker_realty
Sell your house-patrick_parker_realtySell your house-patrick_parker_realty
Sell your house-patrick_parker_realtyJennifer Pricci
 
Multithreading Presentation
Multithreading PresentationMultithreading Presentation
Multithreading PresentationNeeraj Kaushik
 

En vedette (14)

El corporate brochure
El corporate brochureEl corporate brochure
El corporate brochure
 
Concurrent Collections Object In Dot Net 4
Concurrent Collections Object In Dot Net 4Concurrent Collections Object In Dot Net 4
Concurrent Collections Object In Dot Net 4
 
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specification
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specificationImplementation of fix messages for fix 5.0 sp2 and fixt1.1 specification
Implementation of fix messages for fix 5.0 sp2 and fixt1.1 specification
 
No sql
No sqlNo sql
No sql
 
Edison learning cms_manual
Edison learning cms_manualEdison learning cms_manual
Edison learning cms_manual
 
E valuate brochure
E valuate brochureE valuate brochure
E valuate brochure
 
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide)
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide) Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide)
Press Placement; Tri-Town News (Benefit Concert to Shine Light on Teen Suicide)
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
 
Bob burgeronlinepresskit
Bob burgeronlinepresskitBob burgeronlinepresskit
Bob burgeronlinepresskit
 
Z100 clearchannelgeneralcapabilities
Z100 clearchannelgeneralcapabilitiesZ100 clearchannelgeneralcapabilities
Z100 clearchannelgeneralcapabilities
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
New Directions in Project Management
New Directions in Project ManagementNew Directions in Project Management
New Directions in Project Management
 
Sell your house-patrick_parker_realty
Sell your house-patrick_parker_realtySell your house-patrick_parker_realty
Sell your house-patrick_parker_realty
 
Multithreading Presentation
Multithreading PresentationMultithreading Presentation
Multithreading Presentation
 

Similaire à Implement Search Screen Using Knockoutjs

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desaijinaldesailive
 
Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)IT PROGRAMMING WORLD
 
Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.Amar Shukla
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular jscodeandyou forums
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014Dariusz Kalbarczyk
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4Naga Muruga
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosLearnimtactics
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersCaldera Labs
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083Divyam Pateriya
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 

Similaire à Implement Search Screen Using Knockoutjs (20)

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 

Plus de Neeraj Kaushik

How to place orders through FIX Message
How to place orders through FIX MessageHow to place orders through FIX Message
How to place orders through FIX MessageNeeraj Kaushik
 
DotNet &amp; Sql Server Interview Questions
DotNet &amp; Sql Server Interview QuestionsDotNet &amp; Sql Server Interview Questions
DotNet &amp; Sql Server Interview QuestionsNeeraj Kaushik
 

Plus de Neeraj Kaushik (7)

How to place orders through FIX Message
How to place orders through FIX MessageHow to place orders through FIX Message
How to place orders through FIX Message
 
Futures_Options
Futures_OptionsFutures_Options
Futures_Options
 
Linq Introduction
Linq IntroductionLinq Introduction
Linq Introduction
 
Quick Fix Sample
Quick Fix SampleQuick Fix Sample
Quick Fix Sample
 
DotNet &amp; Sql Server Interview Questions
DotNet &amp; Sql Server Interview QuestionsDotNet &amp; Sql Server Interview Questions
DotNet &amp; Sql Server Interview Questions
 
Design UML diagrams
Design UML diagramsDesign UML diagrams
Design UML diagrams
 
Design UML diagrams
Design UML diagramsDesign UML diagrams
Design UML diagrams
 

Implement Search Screen Using Knockoutjs

  • 1. Implement Search screen using knockoutjs, Jquery and asp.net mvc3 Neeraj Kaushik This article demonstrates implementation of knockoutjs observable viewmodel and how to bind viewmodel with html controls. www.dotnetdlr.com [Type text] Page 0
  • 2. http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net- mvc3-2/ Here I am trying to explain steps for how to use knockoutjsviewmodel, jqueryajax request in asp.net mvc3 project. I am taking practical example to show behaviour. This example will have simple UI screen with search textbox and button. When click on search button ajax request will go to server and will call action method of controller class which will return results in json format, then we will see how json result will bind to viewmodel and html controls. Following is flow of information across different layers: Let’s start implementation. Implementation Model Create model class Employee. class Employee { publicintEmployeeID { get; set; } public string Name { get; set; } public string Address { get; set; } public string Phone { get; set; } public string Dept { get; set; } } Controller Create Controller class in controller folder i.e. EmployeeController Implement Action method “Search” which will search on empname. publicJsonResult Search(string EmpName) { varemplist = PrepareEmpList(); varsearchedlist= from emp in emplist whereemp.Name.Contains(EmpName) selectemp; returnJson(new { Items = searchedlist}); } 1
  • 3. http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net- mvc3-2/ private static List PrepareEmpList() { varemplist = new List(); //create list of employee for (inti = 0; i< 20; i++) { varemp = new Employee(); emp.EmployeeID = i; emp.Name = string.Format("Employee-{0}", i); emp.Address = string.Format("ABC New Delhi- 1{0}", i); if (i % 2 == 0) emp.Dept = "IT"; else emp.Dept = "Admin"; emplist.Add(emp); } returnemplist; } In above code controller has action method “Search” which has code to search on supplied search condition and send back result in json object. View @{ ViewBag.Title = "Employee Search"; Layout = "~/Views/Shared/_Layout.cshtml"; } @section head{ <script src="../Scripts/knockout-2.0.0.js"></script> } <h2> Employee List</h2> <div> Search:<input type="text" data-bind="value:empname" /> <input type="button" id='btnSearch' title="Search" value="Search"/> </div> <table style="border-style:solid;border-width:1px"> <thead style="background-color:Gray"> <tr> <th> ID </th> <th> Name </th> <th> Address </th> <th> Phone </th> 2
  • 4. http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net- mvc3-2/ </tr> </thead> <tbody data-bind="foreach: employeemodel.employees"> <tr> <td data-bind="text: EmployeeID"> </td> <td data-bind="text: Name"> </td> </tr> </tbody> </table> <input type="text" data-bind="value:empname" /> this is input text box which is bind to empname property of knockoutjsviewmodel which is defined in javascript file. <tbody data-bind="foreach: employeemodel.employees"> This will use for looping in viewmodel’s observable collection. Note: “data-bind” attribute is used to bind knockoutjsviewmodel. View Model Viewmodel is defined in java script file. This viewmodel also has search function which sends ajax request to “Search” action method on server and receive jsonresult . Employee.js varemployeemodel; $(document).ready(function () { //initializing viewmodel employeemodel = new viewModel(); //binding for ko ko.applyBindings(employeemodel); //bind event $("#btnSearch").click({ handler: employeemodel.search }); //call search method //employeemodel.search(); }); functionviewModel() { var self = this; self.employees = ko.observableArray([]); self.empname = ko.observable(''); self.search = function () { $.ajax({ url: "Employee/Search", data: { EmpName: self.empname }, type: "POST", success: function (response) { 3
  • 5. http://dotnetdlr.com/2012/03/28/implement-search-screen-using-knockoutjs-jquery-and-asp-net- mvc3-2/ //bind data self.employees(response.Items); self.DeptId(response.DeptId); } }); } } Output You can find code here. 4