Skip to content

Instantly share code, notes, and snippets.

@bilalbhojani24
Created February 5, 2026 09:53
Show Gist options
  • Select an option

  • Save bilalbhojani24/43f480179ebb25e1c89edc107c8f89a1 to your computer and use it in GitHub Desktop.

Select an option

Save bilalbhojani24/43f480179ebb25e1c89edc107c8f89a1 to your computer and use it in GitHub Desktop.
import React from 'react';
import Grid from 'app/core/components/Grid';
function GridExample() {
const data = [
{ role: null, city: 'Bangalore' },
{ role: null, city: 'Hyderabad' },
{ role: null, city: 'Chennai' },
{ role: null, city: 'Mumbai' },
];
const handleRoleChange = React.useCallback(
async (changes: any[], updatedRowData: any) => {
const roleChange = changes.find(change => change.prop === 'role');
if (!roleChange) {
return updatedRowData;
}
// Handle clearing the selection - just return the updated data
const newValue = roleChange.newValue;
const additionalValue = roleChange.additionalValue;
if (!newValue) {
return {
role: {},
city: null,
};
}
// Return the updated row data with the fetched role information and city
return {
...updatedRowData,
role: {
fullName: additionalValue.label ?? '',
title: additionalValue.secondaryLabel ?? '',
id: additionalValue.value ?? '',
},
city: 'Banglore',
};
},
[]
);
return (
<>
<Grid
columns={[
{
header: 'Employee',
data: 'role',
type: Grid.CELL_TYPES.ROLE,
editable: true,
nullPlaceholder: 'Select Employee',
props: {
canClear: true,
filters: {
roleFilter: {
roleState__in: ['TERMINATED', 'ACTIVE', 'ACCEPTED', 'HIRED'],
},
},
shouldUseDefaultFilter: false,
},
},
{
header: 'City',
data: 'city',
type: Grid.CELL_TYPES.TEXT,
},
]}
data={data}
onRowChange={handleRoleChange}
height={300}
/>
</>
);
}
export { GridExample as PageLoad };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment