Bind both the table inside the Div using Knockoutjs

Jan 16 2014 8:54 AM
Hi,
 
I have a requirement to show the employees department wise like below;
 
 Department: Developers                                                                  Count:3
 EmpIDName Salary Action 
 101AAAAA 10000 some buttons  
 102BBBBB 15000  
 103CCCCC 10000 
 
Department:Finance                                                                         Count:2
EmpIDName Salary Action
104xxxxx10000 some buttons
105yyyyyy15000  
 
For the above requirement I designed  my View like below
 
<div data-bind="foreach: Departments">
 <span class="pull-left" data-bind="text: DeptName"></span>
<span class="pull-right" data-bind="text: Count"></span> 
<table>
<thead>
<tr>
<th>EmpID</th>
<th>Name</th>
<th>Salary</th>
<th>Action</th>
</tr>
</thead>
<tbody data-bind="foreach: Employees">
<tr>
<td>
<span data-bind="text: EmpID"></span>
</td>
<td>
<span data-bind="text: Name"></span>
</td>
<td>
<span data-bind="text: Salary"></span>
</td>
<td>
<button type="submit" value="View"></button>
</td>
</tr>
</tbody>
</table>
</div> 
 
Can somebody help with the knockout code. How to bind the data to Div and Table inside in it.
 
Thanks in Advance
Murali Krishna. 

Answers (4)