Sandwich menu from different vendors : example pre-populate a table grid
Introduction
This grid is another example of how the grid can be initialized based on the values entered in a custom field.
Â
The example:
You choose of a sandwich vendor (from a list) and  sandwich-selector table automatically fills with the sandwiches and thier prices for that vendor.
Now you can continue to finish  your order, by entering the number of sandwiches;  toals will be calculated automatically.
The issue has two custom fields:
vendor field. This is a custom field with a select list - containing the vendors for which we have loaded a menu in the database.
a table grid field, showing the sandwiches on sale for a particular vendor
Custom field setup
Create one custom field 'Vendor' of type select list, and add 3 values
Bargain Deli
Normal Deli
Luxe Deli
And note down the customfield id.
Grid configuration
#
# Configuration for the Sandwich Selector table grid
#
#
# table grid configuration
#
gd.columns=vendor,sandwich,price,aantal, totaal, updated
gd.tablename=sandwich_order
gd.filter=false
gd.allowAddRows = false
gd.tracking = true
#
# Pre-populate the table grid with rows from a database table
# based on the parameter customfield (search the correct number in JIRA)
#
gd.query=select vendor,sandwichname,price from sandwichprices where vendor = {0}
gd.query.columns=vendor,sandwich,price
gd.query.parameters=customfield:10150
gd.query.keeponrefresh = none
gd.query.ds=igridtest
gd.ds=igridtest
#
# Configuration of the individual columns
#
col.vendor=Vendor
col.vendor.type=string
col.vendor.editable=false
col.vendor.width=75
col.sandwich=Sandwich
col.sandwich.type=string
col.sandwich.editable=false
col.sandwich.width=200
col.price=Price
col.price.type=number
col.price.editable=false
col.price.width=30
col.aantal=Count
col.aantal.type=number
col.aantal.minvalue=0
col.aantal.maxvalue=10
col.aantal.width=30
col.totaal = Total Price
col.totaal.type = Number
col.totaal.formula = {price} * {aantal}
col.totaal.summary = sum
col.totaal.width=30
col.updated= Updated on
col.updated.name = DT_UPD
col.updated.formatDate = dd-M-yy
Â
SQL Setup
The following file contains the create table statement (mysql dialect) and insert statements to create the table of the different menuse.
sandwichselector.sql