ComboBox Master/Detail

You can use the ComboBox as an item selector, and bind other controls to the combo's selectedItem property:

Country: Luxembourg
GDP (M$/yr): $57,825
Population (thousands): 563
GRP/Capita: $102,708
Rank: 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// This file locates: "Scripts/Lesson/C1Input/ComboBoxMasterDetail.js".
c1.documentReady(function () {
    var theCombo = wijmo.Control.getControl('#theCombo');
 
    // define a template for showing the current item's details
    var detailTemplate = '<div>' +
      '<div>Country: <b>{Country}</b></div>' +
      '<div>GDP (M$/yr): <b>{Gdpm:c0}</b></div>' +
      '<div>Population (thousands): <b>{Popk:n0}</b></div>' +
      '<div>GRP/Capita: <b>{Gdpcap:c0}</b></div>' +
      '<div>Rank: <b>{Id}</b></div>' +
      '</div>';
 
    // combo and selectedItem
    showDetail();
    theCombo.selectedIndexChanged.addHandler(function (s, e) {
        showDetail();
    });
 
    function showDetail() {
        var html = wijmo.format(detailTemplate, theCombo.selectedItem,
            function (data, name, fmt, val) {
                if (wijmo.isString(data[name])) {
                    val = wijmo.escapeHtml(data[name]);
                }
                return val;
            });
        document.getElementById('detail').innerHTML = html;
    }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1InputController : Controller
    {
        // GET: ComboBoxMasterDetail
        public ActionResult ComboBoxMasterDetail()
        {
            return View(Models.Gdp.GetData());
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
@model IEnumerable<Gdp>
 
<h1>
    @Html.Raw(Resources.C1Input.ComboBoxMasterDetail_Title)
</h1>
<p>
    @Html.Raw(Resources.C1Input.ComboBoxMasterDetail_Text1)
</p>
 
<label for="theCombo">@Html.Raw(Resources.C1Input.ComboBoxMasterDetail_Text2)</label>
@(Html.C1().ComboBox<Gdp>().Id("theCombo").Bind(Model).DisplayMemberPath("Country"))
<p id="detail"></p>