Hi Folks - ongoing from my posts regarding deleting (marking deleted) records - I’ve a problem with showing my ‘marked-deleted’ records in a tab panel.
I have a tab with two forms, the first (formA) shows a table view of any records that have been marked for deletion in a particular table.
At start-up I set a table filter parameter to show only records that have not been marked deleted. In the onShow method of the form on which the tab panel sits I remove the table filter parameter so that I can show records that HAVE been marked deleted using a global relationship. I do a similar thing on that forms onHide (restore the filter parameter that is).
When I move from tab to tab - all is well and the relevant data is displayed in the formA table. Showing formB and then moving to a totally different form in the solution (not on the form on which this tab resides) - then back and showing formB again - its all as it should be!
However, clicking formA, then showing a totally different form again - when I return to the tab panel the data in formA is not shown. Table headers are shown but no data.
Moving to the next tab and back again shows the correct data once more?
I’m pretty sure I need to have this code in the onShow of the base form, as putting it on the form in the tab panel seems to slow the process a lot and putting it in the onLoad event would cause the filter NOT to be re-instated when this form was no longer being used (just hidden).
I feel sure I’ve heard of this before on the forum, so please forgive me if I’m asking an old question, but none of my search strings has taken me to a relevant post?
Andrei - thanks for the response - as to your points:-
check that the form’s foundset isn’t shared with some other form that adds more filters;
The forms foundset is based on a table and there are other forms based on that table too - however there are no other filters applied than the filter removed in the display of this one. The other form does use a relationship however! Should this affect other forms based on the same table?
be sure to remove the previous filter before calling addFoundSetFilterParam() on onShow/onHide;
Yes this is the basis of the display - I remove the filter on the display of the parent form onShow method (if I do that on the form in the tab panel it does not remove the filter). The tab form shows up correctly the first time shown - but after moving to a totally different form (not in the tab panel) and return - the data is no longer displayed. I have to go to another tab and return to this tab to re-display the data.
try calling clear() or loadAllRecords() after calling addFoundSetFilterParam().
Since this is a related foundset wont loadAllRecords() cause it to ignore the relationship and load all the records? I’m not sure what the clear() will do in this situation?
If it’s related then you can try formA.foundset.loadAllRecords(); you can’t use foundset’s clear. Also, using controller.loadAllRecords() would make it independent of relation.
It can happen that the two forms, if based on the same relation, have the same foundset. But this is not your case, cause your formA is not based on a relation (or you couldn’t add filter param).
Andrei Costescu:
If it’s related then you can try formA.foundset.loadAllRecords(); you can’t use foundset’s clear. Also, using controller.loadAllRecords() would make it independent of relation.
It can happen that the two forms, if based on the same relation, have the same foundset. But this is not your case, cause your formA is not based on a relation (or you couldn’t add filter param).
I think I’ve confused the issue Andrei - here’s what I have:-
TableA - this has a column MarkedDeleted - and the addTableFilterParam_fabricdeleted is used to ensure only those rows where MarkedDeleted is null or 0 are shown.
I have ‘formTabs’ with 2 forms, formA based on TableA (with a global.relation to show only records where MakedDeeleted is = 1) and formB based on another table.
onShow of formTabs I do removeTableFilterParam_fabricdeleted - the onHide of formTabs I do addTableFilterParam_fabricdeleted.
This works fine on first show and when moving from formA to formB and back.
When I move to a totally different form some place else in the system (formTabs is hidden) and return to formTabs, if formA is the first tab displayed it has no data. I can get the data back by clicking formB tab and back to formA - but why is this and how can I ensure that formA shows data on each view.
So you are using both a global relation and a filter on that table.
On which foundset do you apply the filter?
Cause if you apply the filter to formA’s foundset that would result in no contents in the form, as the form is only showing “deleted” contents because of the relation. Right?
Andrei Costescu:
So you are using both a global relation and a filter on that table.
To which foundset do you apply the filter?
Cause if you apply the filter to formA’s foundset that would result in no contents in the form, as the form is only showing “deleted” contents because of the relation. Right?
Andrei Costescu:
Cause if you apply the filter to formA’s foundset that would result in no contents in the form, as the form is only showing “deleted” contents because of the relation. Right?
That’s correct Andrei - the filter is applied to the formA’s foundset (it uses the same table base as the main form which need to be filtered) which is why I need to remove the table filter - in order to show the MarkedDeleted records - I do this in the onShow of the formTabs.
This actually works well, and the records are shown correctly the first time the formTabs is shown, but when navigating away from the formTabs and back again - that’s when the data is not shown?
It’s obviously something to do with the onShow and onHide methods that are fired when I navigate away from formTabs and back again. Its almost like the filter is re-applied when I navigate away - but not re-removed when I show formTabs again.?
Then why not filter main form’s foundset instead?
It probably happens because data is loaded in formA before you first apply the filter, and then when you do stuff and come back, a loadAllRecords might be applied on formA that will take the new filter into consideration. (thus hiding all records)
So probably first time, although the filter is applied, you still see the records because you did not call formA.foundset.loadAllRecords(), so you are not seeing the actual results of the filter yet.
But you should not filter formA’s foundset if you don’t need that. Just filter the foundset you need.
Andrei Costescu:
Then why not filter main form’s foundset instead?
It probably happens because data is loaded in formA before you first apply the filter, and then when you do stuff and come back, a loadAllRecords might be applied on formA that will take the new filter into consideration. (thus hiding all records)
So probably first time, although the filter is applied, you still see the records because you did not call formA.foundset.loadAllRecords(), so you are not seeing the actual results of the filter yet.
But you should not filter formA’s foundset if you don’t need that. Just filter the foundset you need.
Again - I think I’m not making this clear enough for you Andrei - my appologies!
I only apply the addTableFilterParam to the main table ‘fabric_condition’ - this works and shows only the records where MarkedDeleted = 0 or null - the filter is working.
formA is also based on that table - therefore if shown clean it will show only records where MarkedDeleted is 0 or null - but has a global relation too which limits it to rows with MarkedDeleted - hence without removing the TableFilterParam there would be no records shown on the form.
The correct records are shown in formA the first time the formTabs is selected - therefore:-
a. The addTableFilterParam has been successfully removed and
b. The global relationship has been applied.
The problem is that this state is not reflected when navigating away from formTabs and back again??? Seems like either the TableFilerParam has been reinstated when I navigate away from the formTabs (by design) and the removeTableFilterParam has not been re-run when returning to it - OR - the formA UI is not being updated with the current records - remember it does show the correct records again simply by going to another tab then back again??
No need to apologize. I’m sorry I don’t get it faster . I really thought you apply the filter on formA’s foundset, not to the main form’s - and the two should be different considering that one is related and the other one is not.
This is what disoriented me:
Kahuna:
That’s correct Andrei - the filter is applied to the formA’s foundset (it uses the same table base as the main form which need to be filtered) which is why I need to remove the table filter - in order to show the MarkedDeleted records - I do this in the onShow of the formTabs.
You said in the last post “I only apply the addTableFilterParam to the main table ‘fabric_condition’” - did you mean “I only apply the addTableFilterParam to the main form ‘fabric_condition’'s foundset”?
Can you verify that main form and formA use the same foundset? Just add something like```
application.output(forms.formA.foundset === forms.fabric_condition.foundset);
Andrei Costescu:
You said in the last post “I only apply the addTableFilterParam to the main table ‘fabric_condition’” - did you mean “I only apply the addTableFilterParam to the main form ‘fabric_condition’'s foundset”?
Sorry Andrei i meant table rather than foundset - I was really saying I apply the addTableFilterParam to the table fabric_condition - not to a forms foundset - and this is set at start-up.
Andrei Costescu:
Can you verify that main form and formA use the same foundset? Just add something like```
application.output(forms.formA.foundset === forms.fabric_condition.foundset);
That code returns false Andrei - I figured it would as the two forms are based on the same table but the foundset is obviously different.
One form uses a relation to limit the data shown to where MarkedDeleted is =1 and the other has a tableFilterParam applied (only one is present at a time).
Before start-up there are no constraints on table fabric_condition, at start-up I limit it with addTableFilterParam_fabric, when formTabs opens I do removerTableFilterParam_fabric, and the formA opens with a relationship (show only records with MarkedDeleted = 1).
onHide formTabs I then reapply the addTableFilterParam_fabric. Therefore the table fabric_condition is returned to the state it was before opening formTabs.
I may be completely wrong here Andrei but it certainly appears to be
Ian:
The problem is that this state is not reflected when navigating away from formTabs and back again??? Seems like either the addTableFilerParam has been reinstated when I navigate away from the formTabs (by design) and the removeTableFilterParam has not been re-run when returning to it - OR - the formA UI is not being updated with the current records - remember it does show the correct records again simply by going to another tab then back again??
Ah, now I finally realize you weren’t talking about Foundset filters .
It seems my eyes always jumped over the “table” part of what you were saying and I didn’t want to consider that you would want a global table filter…
Did you try calling formA.foundset.loadAllRecords() after removing the filer on onShow?
Andrei Costescu:
Did you try calling formA.foundset.loadAllRecords() after removing the filer on onShow?
Yes I tried those Andrei.
Remembering the forms are formTabs (parent) formA shows the table.
1st I did a load all records on formA, but of course this shows all records and does not take into account the relationship to show only the rows MarkedDeleted.
2nd I did the load all records on the formTabs parent onShow and this has no effect (as expected).
Make sure you did it on the form’s foundset, not on the controller. Other ideas I do not have right now. You can add a case with a small sample to the support system.
Andrei Costescu:
Make sure you did it on the form’s foundset, not on the controller. Other ideas I do not have right now. You can add a case with a small sample to the support system.
Doh… That fixed it Andrei - thanks for sticking with me through this Andrei - much appreciated!