ผลต่างระหว่างรุ่นของ "CuneiTable"

จาก คูนิฟ็อกซ์ วิกิ
ไม่มีความย่อการแก้ไข
ไม่มีความย่อการแก้ไข
บรรทัดที่ 1: บรรทัดที่ 1:
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 ==
== Define ==
Defining a CuneiTable is essentially declaring a CuneiForm with a few additional class variables. Below is an example of a very basic CuneiTable:
<syntaxhighlight lang="python" line="1">
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
</syntaxhighlight>
''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_xxx''' attributes from the CuneiTable level.''


== Initiate ==
== Initiate ==

รุ่นแก้ไขเมื่อ 15:56, 16 เมษายน 2567

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_xxx attributes from the CuneiTable level.

Initiate

Design & Pre-made Scripts

Notable Sub-routines