2017-10-13 32 views
0

我使用ExtJS的6.x的有三種模式:使用多個模型關聯綁定的

Ext.define('Admin.model.Patient', { 
    extend: 'Ext.data.Model', 

    requires: [ 
     'Ext.data.proxy.Rest', 
     'Ext.data.schema.Association' 
    ], 

    fields: [ 
     { name: 'id', type: 'string' }, 
     { name: 'mrn', type: 'string' }, 
     { name: 'birth_date', type: 'date', format: 'Y-m-d' }, 
     { name: 'sex', type: 'string' }, 
     { name: 'first_name', type: 'string' }, 
     { name: 'last_name', type: 'string' }, 

    ], 

    style: { 
     'font-size': '22px', 
     'color':'red' 
    }, 

    proxy: { 
     type: 'ajax', 
     url: remote.url.patient, 

     reader: { 
      type: 'json', 
      rootProperty: '' 
     } 
    } 

}); 

Ext.define('Admin.model.LabResultGroup', { 
    extend: 'Ext.data.Model', 

    idProperty: 'id', 
    fields: [ 
     { name: 'test_code', type: 'string' }, 
     { name: 'test_name', type: 'string' }, 
     { 
      name: 'patient_id', 
      type: 'string', 
      reference: { 
       parent: 'Patient', 
       inverse: 'lab_results', 
       autoLoad: false 
      } 
     } 
    ], 

    proxy: { 
     type: 'ajax', 
     url: remote.url.labsgroup, 
     reader: { 
      type: 'json', 
      rootProperty: '' 
    } 
}); 

Ext.define('Admin.model.LabResult', { 
    extend: 'Ext.data.Model', 

    idProperty: 'id', 
    fields: [ 
     { name: 'test_code', type: 'string' }, 
     { name: 'test_name', type: 'string' }, 
     { name: 'test_code_system', type: 'string' }, 
     { name: 'result_value', type: 'string' }, 
     { name: 'result_value_num', type: 'string' }, 
     { name: 'collection_datetime', type: 'date', format: 'Y-m-d' }, 
     { name: 'result_datetime', type: 'date', format: 'Y-m-d' }, 
     { 
      name: 'lab_id', 
      type: 'string', 
      reference: { 
       parent: 'LabResultGroup', 
       inverse: 'lab_group', 
       autoLoad: false 
      } 
     } 
    ], 

    proxy: { 
     type: 'ajax', 
     url: remote.url.labs, 
     reader: { 
      type: 'json', 
      rootProperty: '' 
     } 
    } 
}); 

我可以訪問兩個組合框之間LabResultGroup和病人就好(之間的關聯使用綁定),但是當我嘗試訪問LabResult和LabResultGroup之間的關聯時,它不會註冊。

我會在適當的時候張貼小提琴展示我遇到的行爲。有什麼會阻止這樣的模型之間的關聯?

回答

0

它實際上工作!出於某種奇怪的原因,我的LabResult模型中的關聯中的父名稱被取消了。更正了這一點,並且我的關聯綁定正在按預期發射。

(。此外,有一個與API端點我正在訪問一個小問題,我不得不增加一個條件上,它是濾波器的詳細屬性,shmetails。)

這個故事的寓意:名稱是重要!週五愉快地偷看!哈!哈!