如何在batton中获取gridview绑定数据,点击angular和type脚本中的gridview外部



我在gridview外部有按钮btnBack,每当启用这些按钮并有人单击时,我都想获得gridview绑定的数据,或者至少触发loadWorkflow(att,false),这样我就可以获得绑定到gridview的数据。完整代码如下

角度

<tr><input matInput type="text" id="txtHardware" name="txtHardware"
[(ngModel)]="txtAttachment" [hidden]="!showHardware"></tr>
<tr  id="divnavigation" [hidden]="!Showdiv"  >
<td>
<button id="btnBack" (click)="Navigate()" style='cursor: pointer; cursor: hand;background-color: #008CBA;border-radius: 8px;'><i class='fa fa-arrow-left' aria-hidden='true'></i>BACK</button> 
</td>

</tr>
<div class="col-md-12">
<div class="row" [hidden]="!showGrid">
<h4 class="text-info"> Attachments</h4>
<div class="content table-responsive">
<table class="table table-bordered table-responsive-md table-striped text-left">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<!--*ngIf="Model?.length > 0"-->

<tr *ngFor="let att of asyncModelAttachmnts | async  | paginate: { id: 'activities', itemsPerPage: 5, currentPage: p }" >
<td (click)="loadWorkflow(att,false)" style='width:20px;height:20px;cursor: pointer;'>
<!--  <button (click)="loadWorkflow(att)"> {{att.NAME}}</button>-->
{{att.NAME}} 
</td>

</tr>

<tr *ngIf=" !(this.total > 0)  ">
<td colspan="14" style="text-align:center">
No Records Found.
</td>
</tr>
</tbody>
</table>


</div>

</div>

</div>

键入脚本

loadWorkflow(att, flg) {
this.EnableBackButton(att);

this.backward=false;
this.filter = new liveLinkFilter({
doc_id: att.ID, psite_slno: att.psite_slno, FileId: att.ID, LLUserName: "akolleri",
TYPE: att.TYPE, INDEX: att.INDEX, backward: this.backward, firsttime: false, ids: att.Ids, FileName: ""
});
this.txtAttachment=att.ID;

this.asyncModelAttachmnts = this.appService.Getfiles(this.filter).pipe(
tap(res => {
this.page = 1;
this.total = res.TotalNumberOfRecords;
for (let item of res.Results) {
//  this.txtAttachment=item.back_id;
console.log("ids = "+item.Ids);
if (item.Ids.includes('second')) {
this.Showdiv = true;
this.back_fileid=item.Ids;
}
else
this.Showdiv = false;

} 

if (this.total > 10) {
this.showPagination = true;
} else {
this.showPagination = false;
}
}),
map(res => res.Results)
);
}
Navigate()
{
this.backids=this.txtAttachment;
console.log("back id is ="+this.backids.split(',').length);
this.backids=  this.backids.split(',')[this.backids.split(',').length-2];
console.log("back id is ="+this.backids);
this.filter = new liveLinkFilter({
doc_id: this.backids, psite_slno: 0, FileId: this.backids, LLUserName: "akolleri",
TYPE: "", INDEX: 0, backward: false, firsttime: false, ids: "", FileName: ""
});
this.asyncModelAttachmnts = this.appService.Getfiles(this.filter).pipe(
tap(res => {
this.page = 1;
this.total = res.TotalNumberOfRecords;
for (let item of res.Results) {
// this.txtAttachment=item.back_id;

} 

this.showGrid = true;
}),
map(res => res.Results)
);
}
EnableBackButton(att)
{
this.Showdiv = true;this.backward=true;        
}

我还没有看完你的完整代码,所以如果我错了,请纠正我。

因此,单击btnBack,您希望显示特定的部分并调用一个函数。尝试这样做:

<div #yourGridView *ngIf="showGridView">
</div>
<button id="btnBack" (click)="someFunction()"></button>

您的ts将是:

showGridView = false;
someFunction() {
//do your job
this.showGridView = true;
}

最新更新