How to do multi-select for ag-grid from related foundset

Forum to discuss the new web client version of Servoy.

How to do multi-select for ag-grid from related foundset

Postby pitc » Fri Feb 26, 2021 5:55 am

I have a grid that I want to show contents of a related foundset (detail from a master type).
I want to allow multiple selection in the grid.
I do not know how to get the multiple selected rows from the grid - or the equivalent of the selected indexes from the foundset that correspond to the multiple rows selected in the grid.
I thought I only had to set the related foundset property to allow mutliple selection - but this does not work in the grid - still does single selection.
I then thought I have to set the grid option rowSelection='multiple' in the grid property. In the UI this does allow multiple selection but I cannot get the rows or the selected records from the grid - the ag-grid api seems not to be implemented?
I thought I should combine the two (in the foundset and in the grid) but nope.
If anyone has done this I would appreciate it.
This should be documented but I cannot find it in any searches.
The only search I found is in the ag-grid documentation to use their api to getSelectedNodes or rows.

Using Servoy 2020.12.3263

Tom
Tom
prospect-saas.com
pitc
 
Posts: 85
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada

Re: How to do multi-select for ag-grid from related foundset

Postby pitc » Thu Mar 04, 2021 12:11 am

I did not get any replies to this question so I am posting my so-called workaround. Not sure if it s defect or a feature.
To get it to work:
the master - detail relation foundset also has a multi-select flag that must be set true.
I found out by adding a check whenever the master record is selected it will fire the appropriate relation to the detail. The check gets the multi-select flag from the relation and if false it will set to true.
This seems to work for my case.
Code: Select all
var masterRec = masterFoundset.getSelectedRecord();
if(!masterRec.master_to_detail.multiSelect) {
        masterRec.master_to_detail.multiSelect = true;
}

I am not sure it is supposed to work this way.

I assume that on the first onRecordSelection event of the master that I can set the multi-select flag to true and forget about it. But no it does get reset to false every time!
Hope this helps others.
If this is incorrect please respond!
Tom
Tom
prospect-saas.com
pitc
 
Posts: 85
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 1 guest