in 6.1 we are having an issue with a solutionModule form that has an onRecordSelection method.
If the foundset is empty (zero records) in 5.2 the onRecordSelection is not fired. In 6.1 it is fired this is causing errors in our solution.
Our form is a tabpanel with 2 tableviews. We populate the top tableview with order headers and the bottom tableview (order line items) is populated as the user clicks records in the top tableview.
//what to run rec selected
var onSelectMethod = “forms.CRM_0F_customer.invoice_detail()”
//add rec on select
if (onSelectMethod) {
myForm.onRecordSelection = myForm.newFormMethod(“function REC_on_select(event){\n” + onSelectMethod + “\n}”)
}
yes this is changed by many request i did get from more the one customer at Servoy World 2012
Because it was just impossible to know that the foundset that is loaded didn’t have any records
so you do get a selection event if you go from nothing to something but you didn’t get a selection event if you go from something to nothing
So you just have to check for that and maybe do stuff depending on the empty state.
One thing : the event name ‘onRecordSelection’ does not correspond any more with the functionality of it !
Imho there is no record selection in a foundset with 0 records. This breaks existing code and makes the event name wrong…
Better would have been : a new event ‘onFoundsetDataChange’ of something like that that is fired when the form is (UI) ready with loading data (even with 0 records).
Johan wrote :
Because it was just impossible to know that the foundset that is loaded didn’t have any records
I find this one of the biggest problems/obstacles in Servoy ! Servoy loads the data into the form so Servoy would know when it is ready with that and could fire an event I would say
it is now more correct, if you have a foundset that has 1 record that is selected
then a user deleted that last record, then you should get an event that the selection is changed (to nothing), because the selection really changed…
So it is not just loading data, it is really firing selection event because the selection is changed
Its not a foundsetdatachange , thats a bit weird to me. what does that say?
Or do you mean that you want to have an event that fires when a form gets another foundset loaded? But thats another thing.
When a form is loaded with no records I would not expect the onRecordSelection event to fire. This is the issue with the OP.
Harjo:
yes, love this feature!
Provide an example of how you are using firing onRecordSelection event when going from a record to no records? I don’t see how this is useful (seems the same functionality can be put in one of the other form events).
lwjwillemsen:
One thing : the event name ‘onRecordSelection’ does not correspond any more with the functionality of it !
Imho there is no record selection in a foundset with 0 records. This breaks existing code and makes the event name wrong…
I agree with this. Keeping various events and their order of firing straight (onLoad, onShow, onRecordSelection – all with nested forms…) is tough enough as it is. Being very clear when an event is fired is key and this change caught us by surprise.
So it is not just loading data, it is really firing selection event because the selection is changed
I can see the need for such an event.
So make a new event called onFoundsetSelectionChange() and leave the 0nRecordSelection() unchanged because in case of 0 records there is really no record selected !
I hope you see the difference between change and selection…
Or do you mean that you want to have an event that fires when a form gets another foundset loaded? But thats another thing.
Yep, that’s what I meant and that is surely another thing. Think again of that what we miss in Servoy 5 is a UI-event that is called when a tableview-form is ready with (filling with data) and painting. With many (> 10) columns that can take a while and we want to change the order and width of the columns in the onShow() and that goes wrong when Servoy is still painting (and drawing) the columns…
Someone way smarter than me came up with the solution/hack below. Others my find it useful.
//what to run rec selected
var onSelectCode = “if (utils.hasRecords(foundset) && forms.CRM_0Ft__open_invoice.sequence) {
forms.CRM_0F_customer.invoice_detail();
}”
guys, it is not wrong again no selection is also a selection
In java this is exactly the same if i have a list or a table doesn’t matter what, i will get a selection event if it goes from something that is selected to no selection at all.
Thats completely logical.
having a onFoundsetSelectionChange is completely weird, thats just the same, onRecordSelection is just called when a record selection is changed.
For example i think there are people that load tabs to data depending on the selection of the main form, if somehow suddenly the selection is changed to none, then how are they going to clear the tabs that depend on that?
There where about 4 different customers at the same time that all wanted a no selection event, so that they can use that for there stuff i guess like the things above, but i don’t know all the situations.
david:
Provide an example of how you are using firing onRecordSelection event when going from a record to no records? I don’t see how this is useful (seems the same functionality can be put in one of the other form events).
Exactly how Johan explains, we where always workarounding, this stuff, by calling onRecordSelection, also in the first onShow() (in case there where no records), in that case.
And the case, where you deleted the last record in a (related) foundset, and there where buttons or tab’s or elements, depending on the record.
there was no solution for that, because the onRecordSelection was not fired!
I agree with Harjo and Johan, for me this is a nice feature.
Just make sure to document the behavior change in the release notes please, I’m sure I will forget about it when I will migrate large projects to 6.1…
david:
Provide an example of how you are using firing onRecordSelection event when going from a record to no records? I don’t see how this is useful (seems the same functionality can be put in one of the other form events).
Exactly how Johan explains, we where always workarounding, this stuff, by calling onRecordSelection, also in the first onShow() (in case there where no records), in that case.
And the case, where you deleted the last record in a (related) foundset, and there where buttons or tab’s or elements, depending on the record.
there was no solution for that, because the onRecordSelection was not fired!
Thanks, makes sense.
I’d rather have both an onRecordSelection and an onRecordUnSelection event instead of bundling both event triggers into one event.