问题描述:

In the array I'm trying to load into a RoundRectList, the data I want for the label (the full name) is split into 3 items in the array ("FullName" + "MiddleName" + "LastName"). When I build the JsonRestStore, I can't simply write

var store = new JsonRestStore({ target: url, allowNoTrailingSlash: 1, labelAttribute: "FullName" + "MiddleName" + "LastName" });

because then it shows up as looking for an item named "FullNameMiddleNameLastName". If I set the three options as a variable and pass it in as a labelAttribute, it has the same effect.

Is there some way to do what I'm wanting to in the labelAttribute of the JsonRestStore?

网友答案:

I'm not sure whether you mean dojo/store/JsonRest or dojox/data/JsonRestStore, but luckily I believe both of them support this:

var store = new JsonRestStore({
    target: url,
    getLabel: function(i) {
        return i.FullName + " " + i.MiddleName + " " + i.LastName;
    }
});

I could only find it in the dojox docs though: http://dojotoolkit.org/api/1.8/dojox/data/JsonRestStore#getLabel

网友答案:

You might also want/need to override getLabelAttributes as it is part of the Read api. But by default, it just returns [this.labelAttribute].

相关阅读:
Top