Dojo - 组合框中的dijit多列

时间:2011-02-05 18:37:08

标签: dojo multiple-columns

如何编写包含多个列的dijit自动完成组合框,例如...

  1. john,doe,cod 13,street sample 1
  2. steve,smith,cod 14,street sample 2
  3. micheal,james,cod 14,street sample 3
  4. 这是我的代码:

    var filteringSelect = new dijit.form.ComboBox({
        id: "managerSelect",
        name: "managers",
        value: "",
        store: managerStore,
        searchAttr: "serial"
        },
    "managerSelect");
    }
    

    但是它只显示如下一列:

    1. 约翰
    2. 史蒂夫
    3. 迈克尔

1 个答案:

答案 0 :(得分:3)

如果我理解正确,您需要覆盖组合框的“labelFunc”。例如。

//定义组合框

var filteringSelect = new dijit.form.ComboBox({
                    id: "managerSelect",
                    name: "managers",
                    value: "",
                    store: managerStore,
                    searchAttr: "serial",
                    labelFunc:"myLabelFunc"
                    },
                    "managerSelect");
                }

// define labelFunc

function myLabelFunc(item, store){
            var label=store.getValue(item, 'first')+","+store.getValue(item, 'last');
            return label;
        }

HTML page - Example