2013-07-19 36 views
1

我有一個rallygrid,我正在填充數據和一些自定義列。一:我想是按月或按季度投資組合項目的純文本表示是基於其計劃的開始日期和結束日期相關的列:拉力網格列渲染更改onUpdate

{ 
    text: 'Date Range', 
    dataIndex: 'PlannedStartDate', 
    renderer: function(value, meta, record) { 
     var date = new Date(value); 
     return App._getSpan(new Date(record.data.PlannedStartDate), new Date(record.data.PlannedEndDate)); 
} 

的_getSpan()方法的工作,並在頁面加載網格很好地填充。但是,如果在保存更改時對網格(所有者,名稱等)中顯示的其中一個字段進行內聯編輯,則記錄更新並且不會獲取PlannedStartDate和PlannedEndDate字段,因此當我撥打

new Date() 

在它們上面,時間倒轉到時間0(1969年12月31日)。

我對此的混亂解決方案是檢查是否在渲染器函數中設置了開始日期和結束日期,如果沒有,則使用另一個查詢來查找通過其ID找到的對象並獲取所有必要的信息。我開發的查詢出錯了,出於某種原因,這意味着當我更改其他字段時,它會保存狀態,但不會嘗試再次使用錯誤的數據呈現此列!

在你的代碼中有一個錯誤讓它工作很不直觀 - 雖然這裏發生了什麼?

回答

0

的解決方案是使用record.raw而非record.data - 在原始的信息保持完整

{ 
    text: 'Date Range', 
    dataIndex: 'PlannedStartDate', 
    renderer: function(value, meta, record) { 
     var date = new Date(value); 
     return App._getSpan(new Date(record.raw.PlannedStartDate), new Date(record.raw.PlannedEndDate)); 
}