CuneiTable

จาก คูนิฟ็อกซ์ วิกิ

CuneiTable is designed specifically to enable in-line data entry. Design-wise, it is more limited than CuneiForm since design flexibility is not highly expected from table-rype objects. In essence, CuneiTable is a wrapper for the accompanying CuneiForm, whether that form be the in-line type or the full expansion type.

Define

Defining a CuneiTable is essentially declaring a CuneiForm with a few additional class variables. Below is an example of a very basic CuneiTable:

class AccCodeTable(CuneiTable):
    MASTER_colsizes = [10, 20, 50, 20]
    MASTER_colnames = ["StID", "Account Code", "Account Name", "Account Group"]
    MASTER_coltypes = ["int", "str", "str", "sel"]
    MASTER_choicecols = ["accgrp"]
    MASTER_choices = [[
                         ("1", "1: Asset"),
                         ("2", "2: Liability"),
                         ("3", "3: Equity"),
                         ("4", "4: Revenue"),
                         ("5", "5: Expense")
                     ]]
    MASTER_firstonly = ["stid"]
    class SubForm(FlaskForm, CuneiSubForm):
        stid = StringField("StID")
        code = StringField("Code", validators=[InputRequired("Required!")])
        name = StringField("Name", validators=[InputRequired("Required!")])
        accgrp = SelectField("Group", default=1)
        def validate_stid(self, stid):
            # Validation goes here

The subclass SubForm is defined like the stripped down version of CuneiForm. Only put fields and validation logics here. All other behaviours are controlled by the MASTER variables from the CuneiTable level.

The Holy Trinity of CuneiTable

The 3 MASTER variables listed below are required for all CuneiTable classes.

  • MASTER_colnames ([str,]): The list of column headers to appear on the page.
  • MASTER_coltypes ([str,]): The list of column value types. Available types include:
    • All types listed in the main article for CuneiForm.
    • 'str': Normal string value.
    • 'check': Value represented by a checkbox.
    • 'sel': Value with multiple choices. In other words, this is equivalent to a drop-list field in forms. In the same fashion, the displayed values for this type is not exactly the same as the values stored in the database. The raw value must pass through a map first before being displayed.
    • 'rad': Similar to 'sel', but this value type is represented by a radio buttons in multiple sub-columns instead.

Table with a Separate Form Modal

Making a table with fullform? You can stop this section here.

In-line Form with Expansion

Choices and Radios

Search and Fill

Instant Calculation

Auto-numbering Function

Other Table Definition Variables

Initiate

Design & Pre-made Scripts

Notable Sub-routines