changing related foundset in a tabpanel

Hi all

I have a ‘Sale’ form which collects all sorts of data about a contact, sale id, date etc. It has a tabpanel showing a list of line items belonging to this sale. These line items are created via the tabpanel so are related to the main sale id.

I want to be able to reduce the foundset in the line items form so that I can show just the items in a certain category.

It is best explained by the screenshot. If the client changes the drop down menu in the ‘line items’ tab, I want to show only whatever they’ve chosen (i.e. if they choose appliances, I want the related foundset in the line items tab to show only appliances for this sale, similarly for all other categories). If however, they choose a category and click ‘add’, I want it to add a line for the chosen category, and if they click ‘load all line items’, I want it to show all lines for this sale.

My question then is how do you filter a related foundset in a tabpanel while keeping the parent form and record.

Thanks for any help

Bevil

I would make the tabpanel non-related and select the foundset for the form via a query. Or you make a new relation adding the category using a global setting on the left hand side.

Makes sense?

Hi Marcel,

Yeah, that makes sense. The question then though is how do I relate back from the line items to the parent record? Obviously I never want to show line items that don’t belong to a particular sale, therefore onLoad needs to isolate just the records from the parent sale record. If it is unrelated, how does it know to get just those records? this would be the same for creating new records, how do you know what your sale pk is when your newRecord() method is being run from an unrelated form?

ps, did you see the Calendar button in the navigator :D

Best

Bevil

Well, you have your main form so creating a new record can be done through a method on that form.

onLoad needs to isolate just the records from the parent sale record

Not onLoad but onShow and that will not give you predictable results since both are sort of ‘one-time-operations’.
The first only on load of the form and the second only on show.
You should do this on record selection and such can/should be triggered on the main form again.

Hope this helps.

What do you use that Calendar button for :lol:

Hmmmm

I don’t want to have a ‘new line item’ outside the tab as all the other tabs have ‘new line’ in them (for consistency.)

Am I approaching the whole thing the wrong way? Edward suggested I have a tabless tabpanel, would that be a better way of doing this?

The Calendar Button will link to your calendar bean once I buy your license :)

I can see why you can use a tabless panel but, imho, you will have the same issue.

As I said earlier, you can also use a relation based with the category added to it.

One other way that I’ve started using in the last couple of months for similar situations is with dynamic value lists created with a query. The query gets both the parent and child record IDs as well as repopulating the valuelists with the new dynamic lists. In this case you are getting just one parent record so it is a little simpler. With queries containing column values that can then be used in arrays to populate either a foundset (using the ID’s) and/or dynamic valuelists, it gives you a little more flexibilty than straight global+ relationships in both selection (what if you want to show two types of the child records?) and in portability from form to form.

Maybe this isn’t making much sense. I promised David Workman I’d submit it to the Magazine and I’ll try to get it in this weekend if you are interested.

Hi John

I do have dynamic value lists (3 cascading ones) in my list of line items. Marcel’s recommendation to show data via a search rather than through a relationship has solved the problem. I now have an unrelated tab with line items and on record selection in the parent, a search for all line items with that sale id are displayed, I can then search for whatever I like in the line items list (thanks Marcel)

I am not seeing the bigger picture though about your comment and would be interested to see it on Servoymagazine if you’re going to post it…

Thanks

Bevil

Hi Bevil

In our application we solved this problem the same way Marcel suggested and you did now: We use a relationless tab and make a specific search in the client form after user selection on the main form.

If you, John Allen, suggest an other way, I’d be interested, too.

Regards
Birgit

Apart from some simple relations I always work this way. This way YOU are in control 100% instead of Servoy. It is a little more coding but I am a CONTROL FREAK :)