2015-11-13 56 views
0

在此論壇中成功回覆我的第一個問題後,我很高興再次提出。我已經使用Brian Hamm的mehodology在ui-grid中使用ui-select。也許我沒有正確實現,但我有這個問題:如何讓單元格顯示從下拉列表中選擇的值,而不是輸入到數據庫中的值。對於gridoptions如UI-Grid中的Ui-Select用法

柱:

{ field: 'projectorebody_id', 
      name: 'projectorebody_id', 
      displayName: 'Select', 
      cellTemplate: '../app/views/projects/eporebodiesdropdown.html', 
      editDropdownOptionsArray: vm.orebodies, 
      width: '10%' }, 

的celltemplate:

<ui-select-wrap> 
<ui-select ng-model="MODEL_COL_FIELD" theme="selectize" 
    append-to-body="true"> 

    <ui-select-match placeholder="Choose...">{{ COL_FIELD }}</ui-select-match> 
    <ui-select-choices repeat="item.projectorebody_id as item in col.colDef.editDropdownOptionsArray | filter: $select.search"> 
    <span>{{ item.orebodyName }}</span> 
    </ui-select-choices> 
</ui-select> 
</ui-select-wrap> 

UI的選擇,包裝是由布萊恩·哈姆寫了一個指令,它有一個下拉列表不保持打開時效果一個離開列。

目前,ui-select佔據整個小區。它顯示item.projectorebody_id。請參閱下面的圖片。選擇是下拉列。你可以看到它顯示了id(item.projectorebody_id)。下一列,礦體,顯示orebodyName(即,從dropdown..if描述性值的下拉分別顯示這些值,然後我需要此列。

Image of cell with column selected being the ui-select dropdown..you can see it displaying the id of the underlying field

現在下拉的圖像選擇時:

Dropdown when selected

點擊後,即讀取並輸入到數據庫表中,但下拉列表顯示item.orebodyName顯然其projectorebody_id我想要的細胞顯示orebodyName(因爲它將如MS Access)

感謝您的任何幫助。

回答

0

替換COL_FIELD item.orebodyName $ ui-select-match標記中的$ select.selected.orebodyName。 (如果我理解你的問題是正確的!)

+0

謝謝。 ui-select-match在ng-repeat之外,所以不能拿起item.orebodyName ..但我認爲你是在正確的軌道上..必須有COL_?我可以參考這個價值嗎? –

+0

當然,愚蠢的錯誤,編輯 – illiptic

0

我發現該怎麼做..這是使用COL_FIELD困惑了我...我用標準$ select.selected替換[fieldname](ie {{ $ select.selected.orebodyName}}在我的情況),它工作正常。