Adding existing record

A place for users and developers of the Xataface to discuss and receive support.

Postby njw » Mon May 01, 2006 9:36 am

Is there a way to define the select list for the add existing record box? I have a box to attach people to a record, but the select box only shows me the surname. Presumably it assumes the first field is the key (correctly) and that the second field uniquely identifies the record (incorrect). Can I add some SQL code to get it to use the surname and forenames?

Thanks

Neil
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon May 01, 2006 9:45 am

You should be able to use the titleColumn() method in the delegate class to define the columns to be used as the title.

e.g.:

Code: Select all
function titleColumn(){
    return 'FirstName';
}


Or if you want the title to be a concatenation of different fields you could do:

Code: Select all
function titleColumn(){
    return "CONCAT(FirstName,' ',LastName)";
}


Hope this helps

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby njw » Tue May 02, 2006 2:41 am

Attempted this Steve, but nothing changed. I think I need to give you more info.

I have 3 tables: Opportunities, Person and PersonOpps (which has three fields, PersonOppsId, OpportunitiesId and PersonId). I have defined a many-to-many relationship between Opportunities and Person via PersonOpps. When I go to the Person tab in the Opportunities form and click "Add existing record", I get just the surname on the Select List. I would like to have forenames and surname.

So, my questions:

1. Which directory do I put my Program.php file in?

2. Should the Program.php be PersonOpps.php?

3. Why will changing the column title change the data display?

Many thanks

Neil
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue May 02, 2006 8:16 am

Hi Neil.

1. Program.php goes in the tables/Programs directory. PersonOpps.php goes in the tables/PersonOpps.php directory, Person.php goes in the tables/Person directory. etc...

2. The Program.php should be PersonOpps.php only if it is the delegate class for the PersonOpps table.

3. Changing the column title will change the display data because the add existing record form lists the titles of all available records in the destination table. If you don't define a title column it takes this to be the first char or varchar column in the table. In your case it appears to be the surname.

In this case, the delegate class that you need to add the titleColumn() method to is the Person.php delegate class, because it appears the the Person table is the destination table of your relationship.

Hope this helps.

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved