Extending the select widget-type

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

Postby prestoy » Mon Jan 22, 2007 8:32 am

I've been testing dataface and I'd like to give you lots of credit for this application. I'm already planning to implement a couple of databases in dataface.

But I miss one feature though, which for me will be a significant enhancement of dataface: I'd like to use a database table as the source for the select widget. When I've been designing web interfaces for databases I have many times used select-widgets like these:

Element A
Element B
Element C
Element D
Element E
Element F

The id-attr is a unique key in the source table, and the option text "Element " is from another column in the table. Would you consider implementing a select-widget like this in the near future?
prestoy
 
Posts: 3
Joined: Wed Dec 31, 1969 5:00 pm

Postby njw » Mon Jan 22, 2007 9:22 am

If I understand you right, this already exists. Have a look here, http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists , at Example 3.

Regards

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

Postby prestoy » Tue Jan 23, 2007 5:46 am

If I understand you right, this already exists. Have a look here, http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists , at Example 3.



This is nearly the same thing, but with valuelists you define the select-values in fields.ini for the table. What I would like to see is a way to draw the valuelist from the contents of a table in the database. This table could be defined like this:
CREATE TABLE (
id INTEGER,
desc VARCHAR(100)
}

The the table content may be:
id desc
1 Element A
2 Element B
3 Element C
4 Element D
5 Element E

From this table you can make this select widget:




Element A
Element B
Element C
Element D
Element E


You could obviously skip the id attribute (and hence the id column) in the option tag if the contents of the desc column is unique. I hope I've provided a more understandable description of my wish now... :)

prestoy
 
Posts: 3
Joined: Wed Dec 31, 1969 5:00 pm

Postby prestoy » Tue Jan 23, 2007 5:52 am

It seems that html code for the select widget doesn't show as text even if it is in a pre-tag (see my last comment). Hope this is better:
prestoy
 
Posts: 3
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jan 23, 2007 12:40 pm

Define your valuelist as follows:

[my_valuelist]
__sql__ = "select id,desc from my_table"

Then in your fields.ini file, define your field as follows:
[my_field]
widget:type = select
vocabulary = my_valuelist

This will give you a select list like you describe above.


-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 10 guests

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