简体   繁体   中英

ngx-datatable with modal Angular 8

I am using ngx-tadatable , when I click on the first row which is just the column indices it opens the modal as if I was clicking on a pretty one with the data. Does anyone know how I can stop this mode, making it open only in lines with data. Since this mode is only to be opened when I click on a data line to get it Follows the code.

在此处输入图片说明

macroarea.modal.html

    <div class="row">
        <div class="col-sm-12">
            <div class="card">
                <div class="card-header">
                    <h5>{{ title }}</h5>
                </div>
                <div class="card-body custom-datatable">
                    <ngx-datatable class="bootstrap pointer" [rows]="macroarea" [loadingIndicator]="loadingIndicator"
                        [columns]="columns" [columnMode]="'force'" [headerHeight]="40" 
                        [summaryPosition]="'bottom'" [footerHeight]="40" [rowHeight]="'auto'"
                        [reorderable]="reorderable" [limit]="10" (click)="open(mymodal, $event)"
                        (activate)="onLoadMacroaresDatas($event)">
                    </ngx-datatable>
                </div>
            </div>
        </div>
    </div>

File macroarea.component.ts

    open(content, event) {
        this.modalService.open(content, this.modalOptions).result.then((result) => {
            this.closeResult = `Closed with: ${result}`;
            this.macroName = null;
            this.modalReference = result;
        }, (reason) => {
            this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
        });
    }

I think what you are wanting is a single how selection. Take a look at this one:

http://swimlane.github.io/ngx-datatable/#single-selection

https://github.com/swimlane/ngx-datatable/blob/master/src/app/selection/selection-single.component.ts

and use the select event instead of the click event (because click is at the whole table level).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM