Pink-El Posted June 22 Posted June 22 Hi, I expected something like this: "UnimDBListGrid.Grouping.collapseAll" Not implemented. Ok. I can add a beforeInit function: sender.collapseAllGroups = function() { var grid = this; var groupFeature = grid.getView().getFeature('grouping'); if (groupFeature) { var store = grid.getStore(); store.getGroups().each(function(group) { groupFeature.collapseGroup(group); }); } }; And call it mGrid.JSInterface.JSCall('collapseAllGroups', []); But it does not work. I can`t understand how to call such a simple event. I can`t find any additional information in the help and this forum. Angry Dmytro
Pink-El Posted June 23 Author Posted June 23 before init function beforeInit(sender, config) { // Налаштовуємо висоту елементів config.itemConfig = { height: 50 }; sender.collapseAllGroups = function(gridJSName) { // Отримуємо грід через його JSName var grid = Ext.getCmp(gridJSName); if (grid) { console.log('This is a grid:', grid); // Перевірка, чи це грід // Перевірка, чи є функція групування в features if (grid.features && grid.features.length > 0) { var groupFeature = grid.features.find(function(feature) { return feature.ftype === 'grouping'; // Знаходимо групуючу функцію }); if (groupFeature) { var store = grid.getStore(); // Перебираємо групи та згортаємо їх store.getGroups().each(function(group) { groupFeature.collapseGroup(group); }); } else { console.error('Grouping feature is not available.'); } } else { console.error('No features found or grouping feature is not enabled.'); } } else { console.error('This is not a grid or grid not found!', grid); } }; } As a result of the function execution, 'No features found or grouping feature is not enabled.' How can I collapse all groups? Dmytro
Pink-El Posted June 25 Author Posted June 25 Hello, simple test is attached to this message Dmytro DBListGrid.zip
Sherzod Posted June 26 Posted June 26 22 hours ago, Pink-El said: DBListGrid.zip 2.42 MB · 1 download Hello, Thanks. One possible solution: 1. MainmForm.Script -> function collapseAllGroups(list) { let scroller = list.getScrollable(); let total = list.getStore().getCount(); let index = 0; // show mask list.setMasked({ xtype: 'loadmask', message: 'Collapsing groups...' }); function scrollAndCollapseNext() { if (index >= total) { // hide mask list.setMasked(false); return; } scroller.scrollTo(0, index * 60); setTimeout(() => { list.getViewItems().forEach(function(item) { let group = item.getGroup?.(); if (group && !group.getCollapsed?.()) { group.toggleCollapsed(); } }); index += 5; scrollAndCollapseNext(); }, 150); } scrollAndCollapseNext(); } 2. Usage -> procedure TMainmForm.UnimFormTitleButtonClick(Sender: TUnimTitleButton); begin //UnimDBListGrid1.JSInterface.JSCall('collapseAllGroups', [mGrid.JSId]); JSInterface.JSCallGlobal('collapseAllGroups', [UnimDBListGrid1.JSControl]); end;
Sherzod Posted June 28 Posted June 28 1 hour ago, Pink-El said: Unfortunately, it does not work :-( Hello, It seems you're doing it incorrectly. Are you sure you inserted the JavaScript code into MainmForm.Script and that you're calling it using the JSInterface.JSCallGlobal?
Recommended Posts