2013-02-04 3 views
1

extjs4 MVC 플러스 yii 프레임 워크에서 일하고 있습니다. 서버에서 나오는 jason 파일의 추가 매개 변수에 액세스하고 extjs4의 클라이언트 측에서 처리하는 방법에 대해 집중해야합니다. 내 코드 : - 1) 내 JSON 파일은 다음과 같습니다 - extjs4에extson4의 json 파일에서 추가 매개 변수에 액세스하는 방법은 무엇입니까?

{ 
    'users': [ 
     { 
      "userId": 1, 
      "userName": 'Who will win the series11111111?', 
      "message":"You are welcome", 
     } 
    ] 
}  

2) 내 userModel 클래스 : - 이 파일에서 사용 가능한 속성에는 어떤 '메시지'가 없다.

Ext.define('Balaee.model.sn.UserModel',{ 

extend: 'Ext.data.Model', 

fields: ['userId','userName','password'], 
proxy: 
{ 
    type:'ajax', 
    api: 
    { 
     read:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin', 
     create:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin', 
    },//end of api 
    reader: 
    { 
     type:'json', 
     root:'users' 
    },//end of reader 
    writer: 
    { 
     type:'json', 
     root:'records', 
    },//End of writer 
}//end of proxy 
}); 

3) 그리고 여기 내가 JSON 파일에서 오는 사용자 이름과 메시지 필드에 액세스하기 위하여려고하고 내보기 파일입니다.

Ext.define('Balaee.view...', 
     { 
       extend:'Ext.view.View', 
       store:'kp.UserStore', 
       config: 
       { 
        tpl:'<tpl for=".">'+ 
         '<div id="main">'+ 
         '</br>'+ 
         '<b>userName :-</b> {userName}</br>'+ 
         '<b>message :-</b> {message}</br>'+ 
         '</div>'+ 
         '</tpl>', 
        itemSelector:'div.main',  
       } 
     });// End of login class 

하지만 작동하지 않습니다.이 값은 userName 필드 값을 표시하지만 메시지 필드 값은 표시하지 않습니다.

사실 나는 extjs4의 모델 클래스에서 다루지 않는 메시지 필드에 액세스하려고합니다. 관계가없는이 유형의 필드에 액세스하는 것이 맞습니까? 이 필드 유형에 어떻게 액세스 할 수 있습니까? 제게 제안 해주세요.

답변

1

Ext.data.Model은 정의한 필드에 대해서만 알고 있습니다. 이는 예제 in the documentation에서 분명합니다.

당신이 메시지가보기에 사용 가능하게하려면, 그것은 또한 모델에서 사용할 수 있어야합니다 : 당신의 reply.This 변경에 대한

Ext.define('Balaee.model.sn.UserModel',{ 
    extend: 'Ext.data.Model', 
    fields: ['userId', 'userName', 'password', 'message'], 
    // ... 
}); 
+0

덕분에 문제를 해결하지만,이 유형에 액세스 할 수있는 다른 방법이 모델 필드에 포함하지 않고 필드를? –

관련 문제