JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › adding children to expanded row using groupy
- This topic has 6 replies, 3 voices, and was last updated 1 year, 6 months ago by Markov.
-
AuthorPosts
-
April 26, 2023 at 8:30 am #104771Winston SocialAppsParticipant
I have groupy with a lot of data row in full is around 55k
my datasource:
const dataSource = new window.Smart.DataAdapter({
autobind: false,
dataSource: entitlementBalancesByHR,
groupBy: [’employeeNameForDisplay’],
dataFields: [
‘id: number’,
‘requestTypeCode: string’,
‘requestType: string’,
’employeeName: string’,
’employeeNameForDisplay: string’,
‘year: string’,
‘entitled: number’,
‘used: number’,
‘balanced: number’,
‘pending: number’,
‘selectedRow: bool’
]
});…
and
const onRowExpand = (event?: Event | undefined) => {
…
}is it possible to add a row as new children in onRowExpand?
- This topic was modified 1 year, 7 months ago by Winston SocialApps.
April 27, 2023 at 4:24 am #104781svetoslav_borislavovParticipantHi,
Yes, you can do it, simply use the addRow method.
Here is an example: https://codepen.io/svetoslavjqwidgets/pen/GRYEKjrI hope this helps!
Best Regards,
Svetoslav BorislavovSmart UI Team
https://www.htmlelements.com/April 28, 2023 at 10:24 am #104805Winston SocialAppsParticipantThanks,
It works!Just a follow-up,
how to clear the rows previously added or clear the rows before expand?April 28, 2023 at 12:54 pm #104810MarkovKeymasterHi,
You can delete a row by using the deleteRow method. For example: grid.deleteRow(1); To clear all rows, you can set the Grid’s source property to an empty array or null.
Regards,
MarkovApril 28, 2023 at 3:55 pm #104812Winston SocialAppsParticipantSorry another problem I got, It can add a row using function addRow,
the problem after multiple rows, the whole expanded rows will collapsed.is there any property to set?
i tried———————-
currentHRGrid.beginUpdate();
// add-row
data.forEach((item:EntitlementsBalance, index:number, items:EntitlementsBalance[])=>{
const nextRequestType = index > 0 ? (item.requestType === data[index – 1].requestType ? ” : item.requestType) : item.requestType;
currentHRGrid.addRow({
id:item.id,
employeeName: item.employeeName,
employeeNameForDisplay: item.employeeNameForDisplay,
requestTypeCode: item.requestTypeCode,
requestType: nextRequestType,
year: item.year,
entitled: item.entitled,
pending: item.pending,
used: item.used,
balanced: item.balanced,
},true,(row:GridRow)=>{
console.debug(‘new-row-added:’, row);
});
});currentHRGrid.endUpdate(true);
———————–still same behaviour
also tried putting
grid.refreshView()no luck,
any possible suggestion?
April 30, 2023 at 3:33 am #104814Winston SocialAppsParticipantor is this wierd behaviour is because I used Grid as functional component?
…
const MyComponent:FC=() => {
const {datasource} = useGridHooks();
const {getColumns, onRowExpand} = useGridEvents();useEffect(()=>{
},[])
return (
<Grid
columns={getColumns}
datasource={datasource}
onRowExpand = {onRowExpand}
/>
)
}Is this supported approach?
May 1, 2023 at 2:06 pm #104815MarkovKeymasterHi,
If the Grid is re-rendered, the rows will be in their initial state. We will need a full example in order to check your use case.
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.