Using different widgets

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

Using different widgets

Postby barryrs » Fri Aug 19, 2011 6:37 am

This seems to be something I've run into multiple times.
1. Can I choose which widget to use based on the view? and/or modify the relationship?

ex.
form view of select "TYPE code, Description"
list view of select "TYPE code only"

My solution:
(transaction.php)
function TransactionTypeID__renderCell(&$record)
{ return '<div style="white-space:nowrap">'.substr($record->display('TransactionTypeID'),0,3).'</div>'; }

2. yui_autocomplete Awesome in form view!!!! List view only shows the ClientID number, not the ClientName.
Changing back to select works fine in list. Did I miss something?

I've searched out so many answers to my questions in the forum, thought at least the first part of this might help someone. -Baer
barryrs
 
Posts: 14
Joined: Tue Feb 15, 2011 11:37 am

Re: Using different widgets

Postby ADobkin » Sat Aug 20, 2011 2:56 am

barryrs wrote:2. yui_autocomplete Awesome in form view!!!! List view only shows the ClientID number, not the ClientName.
Changing back to select works fine in list. Did I miss something?


I was actually just working on a similar issue yesterday. And I agree, the yui_autocomplete widget is awesome! (Thanks, Steve!)

However, I don't think the yui_autocomplete widget is appropriate for relationships. I could be wrong, but I think the lookup widget is much better option. You still get a drop-down list of choices, but in this case they are exact matches to the primary key. The yui_autocomplete widget on the other hand allows for arbitrary data to be entered, which would not match to a primary key. I think it is best suited to regular varchar-type fields where arbitrary data is entered but often repeated in other records.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Using different widgets

Postby shannah » Mon Aug 22, 2011 1:59 pm

form view of select "TYPE code, Description"
list view of select "TYPE code only"


Why not use grafted fields to create different columns. Make one visible in list view and the other visible in form view. By default grafted fields don't show up on the edit form anyways so you only need to worry about hiding one of the fields in list view.

e.g.
Code: Select all
__sql__ = "select t.*, t.TransactionTypeID as TransactionCode from Transactions"

[TransactionTypeID]
    widget:type=select
    visibility:list=hidden
    visibility:find=hidden
    widget:label="Transaction Type"
    vocabulary=TransactionTypeIDs


[TransactionCode]
    widget:label="Transaction Type ID"


or something along those lines.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Using different widgets

Postby barryrs » Fri Aug 26, 2011 4:52 am

Awesome answer, as always!!! Thank you!!!
barryrs
 
Posts: 14
Joined: Tue Feb 15, 2011 11:37 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 2 guests

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