lookup widget help

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

lookup widget help

Postby forbin3000 » Tue Jun 08, 2010 4:54 pm

Hello,

I'm trying to use a lookup widget on the following table and I'm having trouble finding much documentation on lookup widgets.

Code: Select all
CREATE TABLE `entity` (
  `Entity_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Tax_ID` varchar(20) DEFAULT NULL,
  `Parent_Entity_ID` int(10) unsigned DEFAULT NULL COMMENT 'Entity_ID of parent',
  PRIMARY KEY (`Entity_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;


The fields.ini file:

Code: Select all
[Parent_Entity_ID]
widget:label = "Parent Entity"
widget:type=lookup
widget:table=entity_consolidated_vw


I was hoping I could use the view entity_consolidated_vw below to customize the lookup widget:

Code: Select all
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `entity_consolidated_vw` AS select `business_org`.`Entity_ID` AS `Entity_ID`,`business_org`.`DBA` AS `Name` from `business_org` union select `individual`.`Entity_ID` AS `Entity_ID`,concat(`individual`.`First_Name`,' ',`individual`.`Last_Name`) AS `Name` from `individual` order by `Entity_ID`;


`entity` is the parent table to the `business_org` and `individual` tables. I want the lookup to place the Entity_ID into the Parent_Entity_ID field in the `entity` table and search based on the union of `business_org`.`DBA` and concat(`individual`.`First_Name`,' ',`individual`.`Last_Name`). The lookup widget is searching on an empty result set. Any help would be greatly appreciated!
forbin3000
 
Posts: 6
Joined: Wed May 19, 2010 3:32 pm

Re: lookup widget help

Postby shannah » Tue Jun 08, 2010 5:21 pm

In general your strategy looks good. Make sure you have specified a primary key for your view in its fields.ini file.
Code: Select all
[myfield]
  Key=PRI
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: lookup widget help

Postby forbin3000 » Tue Jun 08, 2010 6:03 pm

that worked, thanks! Is there any way to disable the "Add New" button since I won't be able to add a new record via the view?
forbin3000
 
Posts: 6
Joined: Wed May 19, 2010 3:32 pm

Re: lookup widget help

Postby shannah » Wed Jun 09, 2010 8:56 am

I think if you set permissions on the view in the delegate class to disallow the 'new' permission (i.e. READ ONLY) it should make the "Add New" button disappear.
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 9 guests

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