Champion
54
Views
5
Comments
[OutSystems Data Grid] Show selected row count
data-grid-reactive
Reactive icon
Forge component by Gonçalo Martins

Hi,


I'm trying to make the event to count automatically the number of rows that are selected from the rowheader on the OutSystems Data Grid Reactive.

I've buitl this function that I put on a script in my module:


function showCheckedCount(gridID) {    

    const grid = new wijmo.grid.FlexGrid(gridID, {}) ;

     sel = grid.rows.filter(r => r.isSelected);    

     cnt = sel.length;    return cnt;

}


But I can't seem to make it work. I can't attach my grid to the existing FlexGrid object. 


Can someone help?

2020-08-05 09-00-16
Gabriel Lundgren

Hello @Andi,


Have you tried using the GetSelectedRowsCount client action?

Champion

That action has to be used pressing a button or a link. I want the behavior of automatically determine the selected row count.

Hello @Andi 

Can you please describe in which particular event you want to get that information?

Also looking for this feature which the grid should have onSelectedRow event. Then we can use GetSelectedRowsCount to show the user number of selected row each time they select the row.

Got a solution that work for my case. Mybe can help other's too for now.


First, create a client action GridOnInitialize which has input of GridWidgetId and set as the handler for Outsystems Data Grid OnInitialize.

Inside of GridOnInitilaize client action

This is the code for the JavaScript

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).rowMetadata._grid._rows._g.onSelectionChanged = function(e) 
{    
$actions.UpdateSelectedRowCount($parameters.GridWidgetId);    
this.selectionChanged.raise(this, e);
};


Next create another client action UpdateSelectedRowCount with input of GridWidgetId

Inside you can use GetSelectedRowsCount client action from OutSystemsDataGrid to update your Local Variable TotalRowSelected.

To sum it up, what happend is when there are changes to the grid, it will trigger this JavaScript that will call client action to update the number of selected row.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.