#104521
Peter
Participant

In the code below “attachment_count” is “CellA”, and “Attachment” is “CellB” in regard to my initial post.

Grid and columns and settings:

var smart_grid_config = {
    dataSource: null,
    appearance: {
        alternationCount: 2,
        showRowHeader: true,
        showRowHeaderSelectIcon: true,
        showRowHeaderFocusIcon: true,
        allowHover: true
    },
    paging: {
        enabled: true,
        pageSize: 30,
        pageIndex: 0
    },
    pager: {
        visible: true
    },
    sorting: {
        enabled: true,
        mode: 'many'
        /*commandKey: 'altKey'*/
    },
    filtering: {
        enabled: true
    },
    editing: {
        enabled: true,
        mode: 'cell',
        addNewRow: {
            autoCreate: true
        }
    },
    selection: {
        enabled: true,
        allowCellSelection: true,
        //allowRowHeaderSelection: true,
        //allowColumnHeaderSelection: true,
        mode: 'extended'
    },
    summaryRow: {
        visible: false,
        editing: true
    },
    behavior: { columnResizeMode: 'growAndShrink' },
    /*keyboardNavigation: true,*/
    columns: [
        {
            label: 'RowId', dataField: 'RowId', width: 0, visible: false
        },
        {
            label: '#', dataField: 'Line_Number', width: 50, freeze: true
        },
        {
            label: 'Template Name', dataField: 'Journal_Template_Name', visible: false
        },
        {
            label: 'Batch Name', dataField: 'Journal_Batch_Name', visible: false
        },
        {
            label: 'Dato', dataField: 'Posting_Date', width: 150, cellsFormat: 'dd-MM-yyyy'
        },
        {
            label: 'Document Type', dataField: 'Document_Type', visible: false
        },
        {
            label: 'Bilagsnr.', dataField: 'Document_No', width: 150
        },
        {
            label: 'Account Type', dataField: 'Account_Type', width: 150, visible: false /*, editor: {
                template: 'autoComplete',
                autoOpen: true,
                dropDownButtonPosition: 'right',
                dataSource: ['Finanskonti', 'Kunder', 'Leverandører']
            } */
        },
        {
            label: 'Konto', dataField: 'Account_No', width: 150
        },
        {
            label: 'Navn', dataField: 'AccountName', allowEdit: false
        },
        {
            label: 'Beskrivelse', dataField: 'Description'
        },
        {
            label: 'Currency', dataField: 'Currency_Code', visible: false
        },
        {
            label: 'Amount', dataField: 'Amount', editor: 'numberInput', visible: false
        },
        {
            label: 'Amount LCY', dataField: 'Amount_LCY', editor: 'numberInput', visible: false
        },
        {
            label: 'GenBusPosGroup', dataField: 'Gen_Bus_Posting_Group', visible: false
        },
        {
            label: 'GenProPosGroup', dataField: 'Gen_Prod_Posting_Group', visible: false
        },
        {
            label: 'VATBusPosGroup', dataField: 'VAT_Bus_Posting_Group', visible: false
        },
        {
            label: 'VATProPosGroup', dataField: 'VAT_Prod_Posting_Group', visible: false
        },
        {
            label: 'Udgift', dataField: 'Debit_Amount', editor: 'numberInput', width:100
        },
        {
            label: 'Indtægt', dataField: 'Credit_Amount', editor: 'numberInput', width:100
        },
        {
            label: 'VAT Amount', dataField: 'VAT_Amount', visible: false
        },
        {
            label: 'BalVAT Amount', dataField: 'Bal_VAT_Amount', editor: 'numberInput', visible: false
        },
        {
            label: 'BalAccount Type', dataField: 'Bal_Account_Type', visible: false
        },
        {
            label: 'Beholdningskonto', dataField: 'Bal_Account_No', width: 150, editor: {
                template: 'autoComplete',
                autoOpen: true,
                dropDownButtonPosition: 'right'
            }
        },
        {
            label: 'BalGenPosType', dataField: 'Bal_Gen_Posting_Type', visible: false
        },
        {
            label: 'On Hold', dataField: 'On_Hold', template: 'checkBox', editor: 'checkBox', visible: false
        },
        {
            label: '', dataField: 'Attachments', cellsVerticalAlign: 'middle', verticalAlign: 'middle', align: 'center', cellsAlign: 'center', width: 80, freeze: 'far', allowEdit: false, 
            template: function (formatObject)
            {
                const data = formatObject.row.data;
                //console.log('data.attachment_count: ' + data.attachment_count);
                if (data.attachment_count < 1)
                {
                    formatObject.template = '';
                }
                else if (data.attachment_count == 1)
                {
                    formatObject.template = init.icons.image.fa_font;
                }
                else
                {
                    formatObject.template = init.icons.images.fa_font;
                }
            }
        },
        {
            label: '', dataField: 'attachment_count', width: 40, allowEdit: false, visible: false
        }
    ],
    onLoad()
    {
        console.log('grid.onLoad');
    }
};

Data fields:

var smart_grid_data_fields = [
    'RowId: string',
    'Line_Number: number',
    'Journal_Template_Name: string',
    'Journal_Batch_Name: string',
    'Posting_Date: date',
    'Document_Type: string',
    'Document_No: string',
    'Account_Type: string',
    'Account_No: string',
    'AccountName: string',
    'Description: string',
    'Currency_Code: string',
    'Amount: number',
    'Amount_LCY: number',
    'Gen_Bus_Posting_Group: string',
    'Gen_Prod_Posting_Group: string',
    'VAT_Bus_Posting_Group: string',
    'VAT_Prod_Posting_Group: string',
    'Debit_Amount: number',
    'Credit_Amount: number',
    'VAT_Amount: number',
    'Bal_VAT_Amount: number',
    'Bal_Account_Type: string',
    'Bal_Account_No: string',
    'Bal_Gen_Posting_Type: string',
    'On_Hold: bool',
    'Attachments: string',
    'attachment_count: number'
];

Grid init:

Smart('#grid', class
            {
                get properties()
                {
                    var config = smart_grid_config;

                    config.dataSource = new Smart.DataAdapter(
                        {
                            dataSource: data_source, // not shown here, but is an array of data rows.
                            dataFields: smart_grid_data_fields
                        });

                    return config;
                }
            });

Also, onLoad in the grid config never seems to fire – at least the line is not written to the console as expected.

  • This reply was modified 1 year, 7 months ago by Peter.