lookup widget help
Archived from the Xataface Users forum.
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!
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
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?
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.