Grid component selection when grouped and detail form

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Grid component selection when grouped and detail form

Postby swingman » Wed Jul 13, 2022 9:20 am

Hi, I'm on 2021.09 Ng client.

I have a list of people showing in a grid-component, the foundSet has multi-select on.
Next to it I have a detail form showing if only one record is selected, if more than record selected I show a form for merging records.

Everything works fine until I try to group the grid, let's say by company or status, expand the group and try to select individual people.
Then the detail form no longer updates to show the correct record.
I tried attaching a method to the onSelectedRowsChanged handler of the grid, but I can't seem to get this to work.

Any ideas how to implement this?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Grid component selection when grouped and detail form

Postby Gabi Boros » Wed Jul 13, 2022 9:47 am

I guess onSelectedRowsChanged is triggered, right? Then to get the selected rows in grouping mode, you should use the getGroupedSelection api.
Gabi Boros
Servoy
Gabi Boros
 
Posts: 399
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: Grid component selection when grouped and detail form

Postby swingman » Wed Jul 13, 2022 9:53 am

Code: Select all
elements.groupingtable_1.myFoundset.foundset.getSelectedRecords()


Gives me the selection before I grouped the grid, not what I have got selected now...
Is this a known bug, or am I doing something the wrong way?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Grid component selection when grouped and detail form

Postby swingman » Wed Jul 13, 2022 9:57 am

Gabi Boros wrote:I guess onSelectedRowsChanged is triggered, right? Then to get the selected rows in grouping mode, you should use the getGroupedSelection api.


Ah, I has missed the API on the component itself, I had only looked at the foundSet.

Thanks Gabi, hopefully this was the missing piece.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Grid component selection when grouped and detail form

Postby Gabi Boros » Wed Jul 13, 2022 9:59 am

in grouping mode you need to use getGroupedSelection to get the selected rows, because what you see in grouping mode is not the foundset anymore, but some internal foundsets created for grouping
Gabi Boros
Servoy
Gabi Boros
 
Posts: 399
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: Grid component selection when grouped and detail form

Postby swingman » Thu Oct 06, 2022 4:26 pm

is there any way to set the selection when the grid is grouped?

Scenario:

The user works on multiple long lists and gets interrupted, jumping between the lists.

For every record select in the lists I record the state of each list, allowing the user to jump between lists but to maintain the position in each list.
I can restore list perfectly and the selection in the foundSet of a detail form, but cannot do the same for the data-grid.

So I end up with the correct list showing, the correct detail record showing, but no record selected in the data-grid...

My other option is to force-ungroup the grid somehow, because when the grid is ungrouped my logic works perfectly...
Is there a way to remove the grouping of data-grid programatically?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Grid component selection when grouped and detail form

Postby swingman » Thu Oct 06, 2022 5:13 pm

OK, I have managed to ungroup:
Code: Select all
var state = elements.data_grid.getColumnState();

//remove grouping
var new_state = JSON.parse(state);
new_state["rowGroupColumnsState"] = "[]";
for (var e = 0; e < new_state["columnState"].length; e++) {
   new_state["columnState"][e]["rowGroupIndex"] = null;
}
//reapply columnstate without grouping
if (JSON.stringify(new_state) != state) elements.data_grid.restoreColumnState(JSON.stringify(new_state));
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 13 guests