2016-04-14 21 views

回答

3

由於對話框open狀態由material-ui組件內部處理,只有這樣,才能做到這一點會在DatePicker使用ref,並呼籲focus()。一個黑客的種類 - 但它的作品..

例子:

<DatePicker 
    ref='datePickerStartDate' 
    errorStyle={componentSyles.error} 
    textFieldStyle={componentSyles.textField} 
    DateTimeFormat={Intl.DateTimeFormat} 
    cancelLabel={cancelLabel} 
    autoOk={true} 
    {...this.props} 
    /> 

<FontIcon 
    onClick={(e) => { this.refs.datePickerStartDate.focus() }} 
    className="material-icons" style={componentSyles.icon}> 
    date_range 
</FontIcon> 
+0

嘿,這偉大工程,謝謝。一個問題:我們在一個動態創建的項目列表中使用它,每個項目都有一個日期選擇器,並且數組索引的上下文始終設置爲數組中的最後一個項目,但是當我們將它用作輸入時,它會起作用精細。任何如何傳遞正確的索引? –

+0

您是否試圖將索引綁定到該函數中?如果是這樣,你能提供一些代碼嗎? –