Page 1 of 1

Search/Filter on add existing record

PostPosted: Tue Feb 28, 2012 12:19 pm
by wisni1rr
Is it possible to make the "add exiting record" in a many to many relationship be either searchable or filterable. I need to narrow the options in the pulldown. It is possible to have thousands of existing records to add to the relationship and it is a little tedious to navigate through them all.

Thanks again!

Re: Search/Filter on add existing record

PostPosted: Tue Feb 28, 2012 12:23 pm
by shannah
Unfortunately I don't have any good solutions for this right now. This is one of the things that is getting a rebuild in Xataface 2.0 - but that won't be ready for a few months.

You can define custom options for this dropdown using the vocabulary:existing directive in the relationships.ini file or the relationshipname__getAddableValues() method in the delegate class.

But these aren't full solutions to get a searchable list.

Re: Search/Filter on add existing record

PostPosted: Tue Feb 28, 2012 2:23 pm
by wisni1rr
Thank you, Steve.

Can't wait till 2.0 is finished. I am very thankful you have created such a fine tool. Bravo!

Re: Search/Filter on add existing record

PostPosted: Mon Sep 03, 2012 2:18 am
by rtresidd
Hi Steve just checking how this update is coming along.
I've got a dropdown list that is filled with a concatenated string that merges a couple of tables..

Basic table layout...
BoardItems:
id_BoardItems > primary key
fk_BoardRevisionId > relationship with BoardRevision

BoardRevisions:
id_BoardRevisions > primary key
fk_BoardTypeId > relationship with BoardType
BoardRevisionNumber > varchar eg 01

BoardTypes:
id_BoardTypes > primary key
BoardNumber > varchar eg 001
BoardName > varchar eg FooBoard

valuelists.ini
[Board_Listing]
; This lookup is used for assigning a Board to a piece of equipment
__sql__ = "SELECT C.id_BoardItems, concat(A.BoardNumber, '-', B.RevisionNumber, '-', A.BoardName, ' - ', C.BoardSerialNumber) AS Board FROM BoardTypes A, BoardRevisions B, BoardItems C Where B.fk_BoardTypeId = A.id_BoardTypes AND C.fk_BoardRevisionId = B.id_BoardRevisions ORDER BY A.BoardNumber, B.RevisionNumber, C.BoardSerialNumber"

Each real world "Board" can be of a specific "Revision" of a specific "Board Type"
so the drop down list gets filled with something like
XXX-YY-BlaType-ZZZZ

This is probably pretty difficult(impossible within the framework) but... I'd like to filter what is available in the drop down list in 2 stages if possible..
There would be 3 drop down boxes in total
First would allow the user to select the "Board Type" and the second one the "Board Revision" (filtered based on what revisions are available for the previously selected board type).
This would provide a filtered list in the final drop down that would list the available serial numbers for that Board Type/Revision.

I'm not really sure how best to tackle this.
There are some javascript examples showing dynamic filtering of drop down lists but I'm not sure exactly how I can hook something like that into the "add existing" form...

We've also used some submit methods generated by onchange handlers to perform a submit without setting a "save" flag and then had the php regenerate the drop down lists based on the submitted information.. But again not sure how I'd put something like that into the framework? also not sure If I can create the three separate drop down boxes on the same form??

Any hints would be appreciated.

Cheers
Richard

Re: Search/Filter on add existing record

PostPosted: Sat Sep 08, 2012 10:19 am
by shannah
In cases where the built-in actions don't do exactly what you want (e.g. in this case), I usually just create a custom action that does exactly what I want. That way you have infinite flexibility.