Question

I'm trying to build a < select > with dijit\dojo having a JsonRest store (obtained by calling a remote Rest service).

the code is:

var storeEntity = new JsonRest({
    target: contextPath + "/api/myEntity/?param=123",
    identifier : "idEntity"
});

var selectEntity = new Select({
    id: "selectEntity",
    name: "selectEntity",
    style: "width:250px",
    store: storeEntity,
    labelAttr : "someProperty"
}, "selectEntityContainer");

with this I can set the label (and it works), but i can't set the id of the values, and i can't also select the values. I know that if my Json has the property "id" it goes automatically as the id of the entries, but if i want to change the attribute taken as id, how i can do it??

Was it helpful?

Solution

According to the API Documentation, there is a property called idProperty in your JsonRest store. So it should be:

var storeEntity = new JsonRest({
    target: contextPath + "/api/myEntity/?param=123",
    idProperty : "idEntity"
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top