0

Lets say there is such form:

{

                                this._dynamicForm =
                                    <DynamicForm dataSource={InvoiceAdHocChargeDataSource.sc()} useAllDataSourceFields={true}>

                                        <FormFieldItem name="feeCode"
                                                       required={true}
                                        />
                                        <FormFieldItem name="description"
                                                       required={true}
                                        />
                                        <FormFieldItem name="price"
                                                       required={true}
                                                       width={100}
                                        />
                                        <FormFieldItem name="quantity"
                                                       required={true}
                                                       width={100}
                                        />
                                        <FormFieldItem name="vatCode"
                                                       required={true}
                                                       width={100}
                                        />
                                        <FormFieldItem name="remarks"/>
                                     
                                    </DynamicForm>
                            }

How it should be filled with current values? Like I have table of records, click on the table - I want the data from the table row to be in the form fields.

I have done that on table click it reacts, gives me console.log output. But what next?

Cannot find in documenation and quick start quide.

Darius.V
  • 737
  • 1
  • 13
  • 29

1 Answers1

0

So the main thing I was missing was

 layout._dynamicForm.editRecord(record);

full method:

protected onInit(layout: page.invoicing.tabs.InvoiceAdHocChargesTabLayout) {


            const onSelectionUpdated = suppressibleFunction((record: InvoiceAdHocChargeDataSource.Record | null) => {
                if (record) {
                    console.log('adhoc on updated' , record);

                    layout._dynamicForm.editRecord(record);


                }
            });

            layout._listGridRecords.selectionUpdated = onSelectionUpdated


            this.tabEvents.onSelectedChanged.add(() => this.load())
            //
            this.editorEventsRecords.editStarted.add(({record}) => {
                // this is running on invoice line double click
                console.log('edit started // this is running on invoice line double click');
                console.log(record);
                this.invoice = record
                this.load()
            })
        }

suppressibleFunction:

export function suppressibleFunction(f: (...args) => any) {
    let suppress = false

    return Object.assign(
        (...args) => suppress ? undefined : f.apply(this, args),
        {
            suppressWith: <T>(f: () => T): T => {
                suppress = true
                const value = f()
                suppress = false

                return value
            }
        }
    )
}
Darius.V
  • 737
  • 1
  • 13
  • 29