brilliant-orangeB
Refine2y ago
3 replies
brilliant-orange

How to exclude a 'point_amount' column from sorting conditions?

``` const columns = React.useMemo<GridColDef<IPointValues>[]>(
() => [
{field: 'id', headerName: 'ID'},
{
field: 'order_id',
flex: 1,
headerName: '',
minWidth: 150,
},
{
field: 'payment_amount',
flex: 1,
headerName: '',
type: 'number',
minWidth: 100,
renderCell: ({ row }) => {
const orderTotalPayment = Number(row.payment_amount).toLocaleString()
return <div>{orderTotalPayment}</div>
},
},
{
field: 'point_amount',
flex: 1,
headerName: '',
type: 'number',
minWidth: 100,
renderCell: ({ row }) => {
const orderPointType = row.order_point_type;
const orderPoint = Number(row.point_amount).toLocaleString();
let orderEditPoint = 0;
let displayValue = null;

if (Array.isArray(row.items) && row.items.length > 0) {
orderEditPoint = row.items.reduce((totalAmount, item) => totalAmount + item.amount, 0);

const displayValueColor = orderEditPoint > 0 ? 'blue' : 'red';
const displaySign = orderEditPoint > 0 ? '+' : '';
displayValue = (
<span style={{ color: displayValueColor }}>
{displaySign}{Number(orderEditPoint).toLocaleString()}
</span>
);
}
Was this page helpful?