2017-10-18 56 views
1

雖然我覺得它並不適用於我的情況類似admin-on-rest: Access row's column data within a Datagrid component如何訪問記錄的內部的顯示/編輯/創建

export const PlantShow = (props) => { 
return (<Show {...props}> 
     <TabbedShowLayout> 
     <Tab label="Analytics"> 
      { record.oneId && <MetricsCharts {...props} manufacturer="one" /> } 
      { record.otherId && <MetricsCharts {...props} manufacturer="other" /> } 
      { record.anotherId && <MetricsCharts {...props} manufacturer="another" /> } 
     </Tab> 
    </TabbedShowLayout> 
</Show>) 
} 

應該有訪問當前記錄的內部,所以我可以介紹一種方法有條件的邏輯..我沒有找到任何有用的道具..我甚至試圖在植物顯示功能注入{record},但也沒有工作。另外DependentInput這裏絕對沒有幫助

謝謝!

回答

2

您必須使用中間組件作爲Show的子項。它會收到記錄道具。

https://codesandbox.io/s/wyln51r907(在posts.js,圍繞PostShow組件

+0

它可以Tab'的'一個子組件在你的情況 – Gildas

+1

這是我落得這樣做:'''常量AllMetricsCharts =({.. .props,record})=>(

{ record.oneId && } [...]
); '''我在'Tab'中用它作爲''' –

相關問題