Hi Kendo Team,
I'm working on a React project where I want to create a common reusable component for the Kendo UI Grid so that if there are any changes in the grid properties or behavior, I only need to update them in one place—this way I avoid updating it across the entire project.
Here's an example of how I'm using the Grid
:
data={orderBy(staffAuditData, sort).map((item) => ({
...item,
[SELECTED_FIELD]: selectedState[idGetter(item)],
}))}
checkboxElement
style={{
height: staffAuditData.length > 0 ? "100%" : "250px",
}}
dataItemKey={DATA_ITEM_KEY}
skip={page}
take={pageSize}
total={metaData.totalCount}
onPageChange={pageChange}
className="pagination-row-cus"
pageable={{
pageSizes: [10, 20, 30, 50, 100, 500],
}}
sort={sort}
sortable={true}
onSortChange={(e) => setSort(e.sort)}
filterOperators={filterOperators}
onDataStateChange={dataStateChange}
onHeaderSelectionChange={onHeaderSelectionChange}
>
<GridColumn title="Affected Staff" field="affectedStaffName" className="cursor-default" />
<GridColumn title="Affected By" field="affectedByStaffName" className="cursor-default" />
<GridColumn title="Section" field="affectedTable" className="cursor-default" />
<GridColumn title="Action" field="actionName" className="cursor-default" />
<GridColumn
title="Date & Time"
cell={(props) => {
let date = props.dataItem.utcDateCreated;
return (
<td className="cursor-default">
{moment.utc(date).local().format("M/D/YYYY")} at{" "}
{moment.utc(date).local().format("hh:mm A")}
</td>
);
}}
/>
</Grid>
So I created two common components:
CommonGridComponent
– which handles the Grid wrapper and works fineCommonGridColumn
– which I'm trying to use to handle columns dynamically
However, when I pass props to CommonGridColumn
, the column doesn't show up in the grid. The same column works when used directly with GridColumn
. Is there a recommended way to create a wrapper for GridColumn
so it behaves correctly?
Any advice or example on how to build a custom reusable GridColumn component would be really helpful.
Thank you!