Serenity: How do I get a foreign key field in EnquiryDetails table get autofilled with the primary key in Enquiry table..

Created on 5 Oct 2017  路  5Comments  路  Source: serenity-is/Serenity

`
namespace Web_DSL.Enquiry {

@Serenity.Decorators.registerClass()
@Serenity.Decorators.responsive()
export class EnquiryDialog extends Serenity.EntityDialog<EnquiryRow, any> {
    protected getFormKey() { return EnquiryForm.formKey; }
    protected getIdProperty() { return EnquiryRow.idProperty; }
    protected getLocalTextPrefix() { return EnquiryRow.localTextPrefix; }
    protected getNameProperty() { return EnquiryRow.nameProperty; }
    protected getService() { return EnquiryService.baseUrl; }

    protected form = new EnquiryForm(this.idPrefix);

    protected getToolbarButtons() {
        let buttons = super.getToolbarButtons();

        buttons.push({

            title: 'Add Details',
            cssClass: 'edit-permissions-button',
            icon: 'icon-people text-blue',

            **onClick: () => {
                new EnquiryDetailsDialog({
                    //can i load EnquiryID  with this EnquiryDetailsDialog..
                   EnquiryId =EnquiryRow.Fields.EnquiryId   //enquiryid is primary key for Enquiry and forignkey for Enquirydetails


                }).dialogOpen();**
            }
        });

        buttons.push({
            title: 'Attach Documents',
            cssClass: 'edit-permissions-button',
            icon: 'icon-people text-blue',
            onClick: () => {
                new EnquiryDocumentsDialog({

                }).dialogOpen();
            }
        });
        return buttons
    }

    protected updateInterface() {
        super.updateInterface();
        this.toolbar.findButton("edit-permissions-button").toggleClass("disabled", this.isNewOrDeleted());
        //this.toolbar.findButton("undo-delete-button").detach();

    }

}

}

`

Most helpful comment

Estrusco...

Thank you so much for your response...it worked...

All 5 comments

Use

new EnquiryDetailsDialog().loadByIdAndOpenDialog(id)

or

new EnquiryDetailsDialog().loadEntityAndOpenDialog(entity)

Estrusco...

Thank you so much for your response...it worked...

You're welcome :D

@Estrusco
@volkanceylan
as u suggested
i did following change
new EnquiryDetailsDialog().loadEntityAndOpenDialog(entity) //entity of parent form i.e enquiry
for the first time onclick of button above form is opened and data filled and i saved it.
for same click second time if data exits i want to load it ..is this possible..
please suggest way..
any help appreciated..

loadByIdAndOpenDialog as suggested.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chintankukadiya18 picture chintankukadiya18  路  3Comments

AmuthaKondusamy picture AmuthaKondusamy  路  3Comments

Shraddha996 picture Shraddha996  路  3Comments

Pinellus picture Pinellus  路  3Comments

dudeman972 picture dudeman972  路  3Comments