2016-09-09 4 views
0

dmodel을 사용하여 생성 된 dstore가 여전히 dstore였으며 모든 dstore 기능을 상속 받았다고 가정했습니다. 그래서이 getRootCollection라는 나열하는 방법이다하지만 난 가게에이 방법을 실행하려고 할 때이 오류와 함께 실패합니다 (그런 기능) 다음TypeError : datastore.getRootCollection이 함수가 아닙니다.

<script> 

    require(
     [ 
     'dojo/_base/declare', 
     'dstore/Memory', 
     'dmodel/extensions/jsonSchema', 
     'dmodel/validators/StringValidator', 
     'dmodel/store/Validating', 
     "dmodel/Model" 
     ], 
    function (declare, Memory, jsonSchema, StringValidator, Validating, Model) { 

     var vMem = (declare([Memory, Validating]))({ 
      Model: jsonSchema(
      { 
       "$schema": "http://json-schema.org/draft-04/schema", 
       "description": "my schema", 
       "type": "object", 
       "properties": { 
        "page": { 
         "type": "object", 
         "properties": { 
          "detailsCanvas": { 
           "description": "test value", 
           "type": "object", 
           "$ref": "#/definitions/details" 
          } 
         } 
        }, 
        "elements": { 
         "type": "array", 
         "items": { 
          "title": "Element", 
          "type": "object", 
          "properties": { 
           "id": { 
            "type": "string" 
           }, 
           "positionX": { 
            "description": "The X coordinate", 
            "type": "number" 
           }, 
           "elementSpecificProperties": { 
            "type": "object", 
            "oneOf": [ 
             { "$ref": "#/definitions/label" } 
            ] 
           } 
          } 
         } 

        } 
       }, 

       "definitions": { 

        "details": { 
         "type": "object", 
         "properties": { 
          "height": { 
           "type": "string" 
          } 
         } 
        }, 

        "label": { 
         "type": "object", 
         "properties": { 
          "value": { 
           "type": "string" 

          } 
         } 
        } 
       } 
      } 

      ) 
     }); 

     vMem.setData(
     { 
      "page": { 
       "detailsCanvas": { 
        "height": "100px" 
       } 
      }, 
      "elements": [ 
       { 
        "id": "1", 
        "positionX": 20, 
        "elementSpecificProperties": { 
         "value": "value_1" 
        } 
       }, 
       { 
        "id": "2", 
        "positionX": 5, 
        "elementSpecificProperties": { 
         "value": "value_2" 
        } 
       } 
      ] 
     }); 

     var blah = vMem.getRootCollection(); //type error - getRootCollection is not a function 


    }); 
</script> 

답변

0

getRootCollection()이 트리 모델의 일부입니다 내 코드입니다 dstore. dstore/Memory 만 믹스합니다. 그래서 그것이 당신이 그 오류를 얻는 이유입니다. 자세한 내용은 documentation of dstore을 확인하십시오.

관련 문제