entity framework - Get the list from 2 relational tables and display -
i have tables "category & subcategory". categoryid "foreign key" in subcategory table. need fetch category , related subcategories , bind in accordion list.
this code:
<div id="accordian" data-bind="foreach:categories"> <div class="panel-heading"> <h4 class="panel-title"><span data-bind="text: categoryname"></span></h4> </div> <div class="panel-body"> <ul data-bind="foreach:subcategories"> <li><a href="#"><span data-bind="text: subcategoryname" ></span></a></li> </ul> </div> </div>
please me on this.
i have created demo fake response should provide via endpoint. there missing self declaration in order have object reference. add following in begging of vm.
var self = this;
i have created fake method simulate fake data array same service should provide.
function ajaxhelperfakeresponse(callback) { var response = [{ categoryname: 'catgeory1', subcategories: [{ subcategoryname: 'subcategoryname1' }, { subcategoryname: 'subcategoryname2' }] }]; callback(response); }
you can see whole solution in fiddler http://jsfiddle.net/jakethashi/ow785abr/
Comments
Post a Comment