I have an object that has a school list with nested classes and nested students in each class
What i need is to bind the optionsText to show the hierarchy so that the dropdown menu shows the options just like :
School A has
Student 1
Student 2
School B has
Student 4
Student 5
Student 6
I am able to get the name of the school on the dropdown but the student part which i am able to get with a foreach on the classes shows as 'undefined' with the binding below.
<select data-bind="options: SchoolList, optionsText: function (item) { return item.School + '|' + item.Classes.forEach(function (item) { return item.Student})}, optionsValue: 'Id', value:SchoolListId, optionsCaption: 'Select'" id="school" name="school" class="school"></select>
Any help will be appretiated,
optionsText: function (item) { return item.School () + '|' + $.map(item.Classes(), function(val,index) { return val.Student()}).join(', '); }
– Jose Luis