2017-07-10 5 views
0

管理ダッシュボードテンプレートでバインディングアソシエーションが動作していません(コンボボックスからレコードを選択し、グリッド内の関連するレコードをプルアップする動作が必要です)。ExtJS管理テンプレート内のデータバインディング関連

Ext.define('Admin.view.pages.Procedure', { 
    extend: 'Ext.panel.Panel', 
    xtype: 'procedure', 

    requires: [ 
     'Ext.panel.Panel', 
     'Admin.model.Patient', 
     'Admin.model.Procedure' 
     //'Admin.model.Diagnosis' 
    ], 

    anchor : '100% -1', 

    referenceHolder: true, 


    width: 1000, 
    height: 1000, 
    referenceHolder: true, 
    layout: { 
     type: 'hbox', 
     align: 'stretch' 
    }, 


    viewModel: 'main', 
    session: {}, 

    items: [ 
     // https://www.sencha.com/forum/showthread.php?299301-Bind-combobox-displayField-value-to-displayfield 

     { 
      xtype: 'fieldset', 
      layout: 'anchor', 
      items: [{ 
       xtype: 'combobox', 
       listeners : { 
        select : function() { 
         console.log(arguments) 
         console.log(arguments[1].data.birth_date) 
         console.log(arguments[1].data.first_name) 
         console.log(arguments[1].data.last_name) 
         console.log(arguments[1].data.sex) 

        } 
       }, 
       bind: { 
        store: '{patients}' 
       }, 
       reference: 'patientCombo', 
       publishes: 'id', 
       fieldLabel: 'Patient Search', 
       displayField: 'mrn', 
       //anchor: '-', 
       // We're forcing the query to run every time by setting minChars to 0 
       // (default is 4) 
       minChars: 2, 
       queryParam: '0', 
       queryMode: 'local', 
       typeAhead: true, 
       // https://www.sencha.com/forum/showthread.php?156505-Local-combobox-with-any-match-filter 
       doQuery: function(queryString, forceAll) { 
        this.expand(); 
        this.store.clearFilter(!forceAll); 

        if (!forceAll) { 
         this.store.filter(this.displayField, new RegExp(Ext.String.escapeRegex(queryString), 'i')); 
        } 
       } 


      }, { 
       // https://www.sencha.com/forum/showthread.php?299301-Bind-combobox-displayField-value-to-displayfield 
       xtype: 'displayfield', 
       fieldLabel: 'Selected Patient', 
       bind: { 
        html: '<p>Name: <b>{patientCombo.selection.first_name}, ' + 
        '{patientCombo.selection.last_name} </b></p>' + 
        '<p>Sex: {patientCombo.selection.sex}</p>' + 
        '<p>Birthdate: {patientCombo.selection.birth_date}</p>' 
       } 


      }] 
     }, 


     { 
      title: 'Procedures', 
      xtype: 'grid', 
      bind: '{patientCombo.selection.procedures}', 
      flex: 1, 
      margin: '0 0 0 10', 
      columns: [{ 
       text: 'Procedure Date', dataIndex: 'proc_date', flex: 1 
      }, { 
       text: 'Procedure', dataIndex: 'proc_name', flex: 1 
      }], 

      plugins: [{ 
       ptype: 'rowexpander', 
       rowBodyTpl : new Ext.XTemplate(
        '<p><b>Proc Name Orig:</b> {proc_name_orig}</p>', 
        '<p><b>Proc Code:</b> {proc_code}</p>', 
        '<p><b>Proc Code Type:</b> {proc_code_type}</p>') 
      }], 

      viewConfig: { 
       emptyText: 'No procedures', 
       deferEmptyText: false 
      } 
     }] 
}); 

:手順ビューされた状態で

{ 
      text: 'Pages', 
      iconCls: 'x-fa fa-leanpub', 
      expanded: false, 
      selectable: false, 
      //routeId: 'pages-parent', 
      //id: 'pages-parent', 

      children: [ 

       { 
        text: 'Proc', 
        iconCls: 'x-fa fa-send', 
        rowCls: 'nav-tree-badge nav-tree-badge-hot', 
        viewType: 'procedure', 
        leaf: true 
       }] 
} 

:私はNavigationTree.jsにあるページへのリーフノードを追加

Ext.define('Admin.view.main.MainModel', { 
    extend: 'Ext.app.ViewModel', 
    alias: 'viewmodel.main', 


    stores: { 
     patients: { 
      model: 'md_registry.model.Patient', 
      autoLoad: true 
     } 
    } 

}); 

私の主なViewModelには、以下のように定義されます私の患者と手技のモデルは簡単です:

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

    idProperty: 'id', 
    fields: [ 
     //{ name: 'id', type: 'string' }, 
     { name: 'proc_code', type: 'string' }, 
     { name: 'proc_name', type: 'string' }, 
     { name: 'proc_code_type', type: 'string' }, 
     { name: 'proc_name_orig', type: 'string' }, 
     { name: 'proc_date', type: 'date', format: 'Y-m-d' }, 
     { 
      name: 'patient_id', 
      type: 'string', 
      reference: { 
       parent: 'Admin.model.Patient', 
       //type: 'md_registry.model.Patient', 
       inverse: 'procedures', 
       autoLoad: false 
      } 
     } 
    ], 

    proxy: { 
     type: 'rest', 
     url: 'http://127.0.0.1:5000/procedureview/api/read', 
     reader: { 
      type: 'json', 
      rootProperty: '' 
     } 
    } 

}); 

それぞれ

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

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

    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' } 
    ], 

    proxy: { 
     type: 'ajax', 
     url: 'http://127.0.0.1:5000/patientview/api/read', 
     reader: { 
      type: 'json', 
      rootProperty: '' 
     } 
    } 

}); 

私の患者ストアのデータがうまくコンボボックスにロードされ得ているが、私はコンボリストから項目を選択するとき、関連する手順データをつかむために電話をオフに発射されていません(画像参照:。of no binding association

... of working binding association、そして予想通り、オブジェクトのプロトタイプチェーン内に表示、管理ダッシュボードの一方(

associations bound to model

を参照してください。

しかし、結合団体は(画像を参照してくださいサイドナビゲーションタブで期待どおりに動作します、関連は空です)。

私の人生では、管理ダッシュボードでこれらの作業を行うことはできません。私はバインドインスペクタと呼ばれるツールに気づいたが、私はSDKのGPLバージョンを実行しているので、これにアクセスすることはできない。これ以外にも、バインディングアソシエーションが管理ダッシュボードで動作しない理由をデバッグする方法はわかりませんが、それ以外の場合はサイドナビゲーションタブで完全に機能します。

私はフィドルを設定しますが、管理用テンプレートを使用してそれを行う方法はわかりません。

答えて

0

私はそれを理解しました。これは名前空間の問題でした。手順モデルで

私の参照は次のようになります。

reference: { 
       parent: 'Patient', 
       inverse: 'procedures', 
       autoLoad: false 
      } 

出来上がり予想通り、すべての関連データがロードされます!

関連する問題