lundi 29 février 2016

create drop down list with optgroup in ember

I very new to ember. I want all parent values should be displayed as dropdown label and all child values should displayed as detail value. Both parent and child is refering to same model.

Json Object res.send({ 'data': [{ "id": "1", "type": "category", "attributes": { "created-by": 1, "created-date-time": "2016-01-18T16:36:55", "description": "color", "name": "color", "value": "Color", "order": 1, "updated-by": 1, "updated-date-time": "2016-01-18T00:00:00" }, "relationships": { "children": { "data": [{ "id": "11", "type": "category" }, { "id": "12", "type": "category" }] }, "parent": { "data": null

          },
          "templates": {
              "data": []
          }
      }
  }],
  "included": [{
      "id": "11",
      "type": "category",
      "attributes": {
          "created-by": 1,
          "created-date-time": "2016-01-18T00:00:00",
          "description": "Red",
          "name": "Red",
          "value": "Red",
          "order": 1,
          "updated-by": 1,
          "updated-date-time": "2016-01-18T00:00:00"
      },
      "relationships": {
          "children": {
              "data": []
          },
          "parent": {
              "data": {
                  "id": "1",
                  "type": "category"
              }
          },
          "templates": {
              "data": [{
                  "id": "1",
                  "type": "templates"
              }]
          }
      }
  },
  {
      "id": "12",
      "type": "category",
      "attributes": {
          "created-by": 1,
          "created-date-time": "2016-01-18T00:00:00",
          "description": "Blue",
          "name": "Blue",
          "value": "Blue",
          "order": 1,
          "updated-by": 1,
          "updated-date-time": "2016-01-18T00:00:00"
      },
      "relationships": {
          "children": {
              "data": []
          },
          "parent": {
              "data": {
                  "id": "1",
                  "type": "category"
              }
          },
          "templates": {
              "data": [{
                  "id": "1",
                  "type": "templates"
              }]
          }
      }
  }]
});

});

model.js

export default DS.Model.extend({
type:DS.attr('string'),
key:DS.attr('string'),
order:DS.attr('string'),
value:DS.attr('string'),
childrenCat:DS.hasMany('children')

});

how can i achieve this?? kindly help me..




Aucun commentaire:

Enregistrer un commentaire