4. field

Last page update: November 23, 2011

Note

field features:

4.1. definition

GnrDomSrc_dojo_11.field(field=None, **kwargs)

TODO

Parameters:field – TODO

4.2. description

field is used to view, select and modify data included in a database table.

Its type is inherited from the type of data contained in the table to which field refers. For example, if field catches data from a NumberTextbox, its type is actually a numberTextbox

field MUST be a child of the formbuilder form widget, and formbuilder itself MUST have a datapath for inner relative path gears. So, field search a form to bind itself to, so don’t forget to link every field to a formbuilder. Here is an example:

class GnrCustomWebPage(object):
    def main(self,root,**kwargs):
        fb = root.formbuilder(datapath='myPathForData')
        fb.field(...) # The field's content will be explained below...

The last thing is to specify the database table to which the field refers to. There are three different possibilities to do this:

4.3. attributes

field attributes:

  • field: MANDATORY - the field’s query path; the complete syntax is packageName.tableName.tableAttributeName. It can be used in a combo with dbtable attribute (a formbuilder attribute) and with the maintable. For more information, check the maintable section.
  • limit: The max number of rows displayed in a field as response to user request. The last line is always a line with no characters, so user can choose it to not perform his request
  • lbl: Set the Field label. Properly, “lbl” is a formbuilder’s child attribute, so if you don’t specify it, then field will inherit it from the name_long attribute of the requested data
  • rowcaption: Allow user to view records through the record’s name_long value. Check for more information on rowcaption page
  • zoom: Allow to open the linked record in its table. For further details, check the zoom page

4.4. Examples

4.5. dbtable on the formbuilder

You can set the dbtable attribute on the formbuilder, like:

class GnrCustomWebPage(object):
    def main(self,root,**kwargs):
        fb = root.formbuilder(datapath='test1',dbtable='showcase.cast')

where showcase is the name of the package and cast is the name of the table. At this point, the field will be like:

fb.field(field='person_id',rowcaption='$name')

So, the first value of the field contains the name of the attribute you want to save in the datastore (for rowcaption explanation, check attributes).

4.6. maintable

In this example we show to you that you can introduce the maintable in the place of the formbuilder dbtable:

class GnrCustomWebPage(object):

    maintable='showcase.cast'

    def main(self,root,**kwargs):
        fb = root.formbuilder(datapath='test2')
        fb.field(field='person_id',rowcaption='$name')

If you have more than one formbuilder, the maintable is being applied to EVERY formbuilder.

4.7. internal dbtable

In this last case we show that you can set the dbtable inside the field:

class GnrCustomWebPage(object):
    def main(self,root,**kwargs):
        fb = root.formbuilder(datapath='test3')
        fb.field(field='showcase.cast.person_id',rowcaption='$name')

In this example, the first field attribute (its query-path) has the syntax packageName.tableName.tableAttributeName. Genro trasforms the field into a dbselect, splitting the query-path in two: packageName.tableName will go as the string applied to the dbtable attribute, while the tableAttributeName will go as the string applied to the value attribute. So, the path of field value will be /test1/person_id/ID, where test1 is the name we chose for the datapath, person_id is the name of the attribute we chose for user query contained in the database model called cast and the ID is the record ID.

Table Of Contents

Previous topic

3. checkBoxText

Next topic

5. formbuilder

This Page