2015-11-05 32 views
1

我正在使用AngularJS UI-Grid。有一個6列和4行的恆定網格。在這個網格中,我有一個特定的要求,其中只有一個單元格是日期選擇器,一個單元格是下拉列表,並且只有很少的單元格是數字。我知道整個專欄可以應用。有沒有辦法將這個應用於特定的單元格?我們可以將單個單元格作爲Datepicker還是下拉菜單?

任何樣品都會有很大的幫助。

在此先感謝。

回答

0

一個選擇是使用一個模板來決定它將與某個row-entity-property相關的單元類型。

我創建了a Plunkr展示這種情況。

的設置由cellTemplate的:

cellTemplate: "<button ng-if=\"!row.entity.datepicker\" ng-click=\"grid.appScope.delete(row)\">DELETE ROW</button><input type=\"date\" ng-if=\"row.entity.datepicker\">" 

而對於這個例子中,我創建了我行的數據一datepicker:true/false屬性。

for(var i = 0; i < 3; i++) { 
    editor.mySeasons.push({myDate: new Date(new Date().getTime() + Math.random().toFixed(12) * 100000000000), datepicker: false}); 
} 
editor.mySeasons.push({myDate: new Date(new Date().getTime() + Math.random().toFixed(12) * 100000000000), datepicker: true}); 

希望有所幫助。