2016-10-04 35 views
0

我需要添加自定義錯誤消息對細胞時,它是在編輯模式下,基本上,我只需要添加的消息可編輯HTML模板如下角UI格,添加自定義消息,editableCellTemplate

<a href=\'#\' data-toggle=\'tooltip\' data-placement=\'top\' title=\'error!\' ng-show=\'!inputForm.$valid\'>errMsg - {{customMsg}}</a> 

我只是爲了測試目的而將customMsg綁定到全局範圍,但它似乎並未出現。樣品plunker這裏補充,這將是一個很大的幫助,如果你能告訴我什麼,我做錯了

感謝

回答

1

你可能想看看這個答案

https://stackoverflow.com/a/28127498/1585304

當你使用ui-grid時,你實際上是在一個孤立的範圍內工作。

這意味着您無法簡單地通過在您的html中鍵入var的名稱來訪問父範圍。

爲了訪問您的customMsg變量,您需要使用grid.appScope來引用父範圍。

您的列定義應該看起來更像這樣。

{ 
     field: 'company', 
     displayName: 'Company', 
     enableColumnMenu: false, 
     editableCellTemplate: "<div><form name=\"inputForm\"> 
     <input type=\"INPUT_TYPE\" ng-class=\"'colt' + col.uid\" 
     ui-grid-editor ng-model=\"MODEL_COL_FIELD\" minlength=3 
     maxlength=10 required><a href=\'#\' data-toggle=\'tooltip\' 
     data-placement=\'top\' title=\'error!\' 
     ng-show=\'!inputForm.$valid\'>errMsg - {{grid.appScope.customMsg}} 
     </a></form></div>" 
    } 

唯一的問題是,真的很難看到消息,因爲形式被行幾乎完全隱藏。

希望這會有所幫助。

+0

非常感謝你..這對我有用。 :) – Dark99