Hi ND,
Greetings from Syncfusion support.
Please find the response for your queries below,
Query – 1: “I have passed template function , but when I do console for props - i can see the particular object but I was unable to access fields.”
Based on the provided information we could understand that your requirement is to access the column field inside the template. You can achieve this by accessing the field as demonstrated in the below code snippet,
|
const template = (props) => {
var colField = props.column.field;
var value = props.OrderID;
return (
<div>
{colField} - {value}
</div>
);
}; |
Query – 2: “In grid component I tried use some conditions but didn't worked.”
From this query we suspect that you are facing problem while trying to render the Grid column directive using conditions. If so, you can achieve the same by using the below code snippet,
|
<GridComponent dataSource={data} height="350">
<ColumnsDirective>
{fields.map((item) => {
return item.field === "OrderID" ? (
<ColumnDirective field={item.field} template={template} />
) : (
<ColumnDirective field={item.field} headerText={item.headerText} />
);
})}
</ColumnsDirective>
</GridComponent> |
We have prepared a sample based on the above queries for your reference. You can find it below,
Please get back to us if you require any further assistance.
Regards,
Sujith R