Datatable saying “No data available in table” even though there is data in the table in angular









up vote
0
down vote

favorite












Actaully I have the data that are fetched through api and are being displayed in datatable in angular.I need to show the two tables in same html page so I have used two datatables but in one of those table I get "No data available in table". If i use single table then there is not this problem.



component.ts file



 constructor(private http: HttpClient,private assignmentAuditService: AssignmentAuditService,private selectionService: SelectionService,
private chRef: ChangeDetectorRef, private chRef1: ChangeDetectorRef,
private authService:LoginAuthService,private auditGroupService:AuditGroupService)
this.authService.isLoggedIn();



ngOnInit()

this.http.get('http://localhost:8080/api/auditgroup')
.subscribe((data: any) =>
this.auditorgroups = data;
console.log(this.auditorgroups);
);

//i have called the api to load data into datatable here this.http.get
('http://localhost:8080/api/selections/getAllNonAuditGroupSelections')
.subscribe((data: any) =>
this.clients = data;
console.log(this.clients);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);

/* for auditgroup selecitonm */

//i have called the api to load data into datatable here
this.http.get('http://localhost:8080/api/selections/getAllAuditGroupSelections')
.subscribe((datas: any) =>
this.nonAuditSelection = datas;
console.log(this.nonAuditSelection);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef1.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);




html to display table



<h5>Selection Without Audit Group</h5>
<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let client of clients" (click)="onClick(client)">
<td [ngStyle]="getStyle(this.client)">client.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td [ngStyle]="getStyle(this.client)">client.selectionDate</td>
<td [ngStyle]="getStyle(this.client)">client.selectedBy</td>
<td [ngStyle]="getStyle(this.client)">client.panEximNumber</td>
<td [ngStyle]="getStyle(this.client)">client.name</td>
<td>client.address</td>
<td>client.phoneNumber</td>
<td>client.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>

<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let nonAudit of nonAuditSelection">
<td>nonAudit.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td>nonAudit.selectionDate</td>
<td>nonAudit.selectedBy</td>
<td>nonAudit.panEximNumber</td>
<td>nonAudit.name</td>
<td>nonAudit.address</td>
<td>nonAudit.phoneNumber</td>
<td>nonAudit.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>


Table is diplayed as :



enter image description here



The api datas are coming right as here is no problem :



enter image description here










share|improve this question























  • Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
    – undefined
    Nov 11 at 7:36










  • yes the values coming in two tables are from two different api's
    – ashwin karki
    Nov 11 at 7:41










  • in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
    – ashwin karki
    Nov 11 at 7:42










  • From where that text no data is comming from api or you gave it manually??
    – undefined
    Nov 11 at 7:59










  • No No jquery will detect the no of values and show them automatcially
    – ashwin karki
    Nov 11 at 8:48














up vote
0
down vote

favorite












Actaully I have the data that are fetched through api and are being displayed in datatable in angular.I need to show the two tables in same html page so I have used two datatables but in one of those table I get "No data available in table". If i use single table then there is not this problem.



component.ts file



 constructor(private http: HttpClient,private assignmentAuditService: AssignmentAuditService,private selectionService: SelectionService,
private chRef: ChangeDetectorRef, private chRef1: ChangeDetectorRef,
private authService:LoginAuthService,private auditGroupService:AuditGroupService)
this.authService.isLoggedIn();



ngOnInit()

this.http.get('http://localhost:8080/api/auditgroup')
.subscribe((data: any) =>
this.auditorgroups = data;
console.log(this.auditorgroups);
);

//i have called the api to load data into datatable here this.http.get
('http://localhost:8080/api/selections/getAllNonAuditGroupSelections')
.subscribe((data: any) =>
this.clients = data;
console.log(this.clients);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);

/* for auditgroup selecitonm */

//i have called the api to load data into datatable here
this.http.get('http://localhost:8080/api/selections/getAllAuditGroupSelections')
.subscribe((datas: any) =>
this.nonAuditSelection = datas;
console.log(this.nonAuditSelection);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef1.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);




html to display table



<h5>Selection Without Audit Group</h5>
<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let client of clients" (click)="onClick(client)">
<td [ngStyle]="getStyle(this.client)">client.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td [ngStyle]="getStyle(this.client)">client.selectionDate</td>
<td [ngStyle]="getStyle(this.client)">client.selectedBy</td>
<td [ngStyle]="getStyle(this.client)">client.panEximNumber</td>
<td [ngStyle]="getStyle(this.client)">client.name</td>
<td>client.address</td>
<td>client.phoneNumber</td>
<td>client.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>

<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let nonAudit of nonAuditSelection">
<td>nonAudit.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td>nonAudit.selectionDate</td>
<td>nonAudit.selectedBy</td>
<td>nonAudit.panEximNumber</td>
<td>nonAudit.name</td>
<td>nonAudit.address</td>
<td>nonAudit.phoneNumber</td>
<td>nonAudit.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>


Table is diplayed as :



enter image description here



The api datas are coming right as here is no problem :



enter image description here










share|improve this question























  • Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
    – undefined
    Nov 11 at 7:36










  • yes the values coming in two tables are from two different api's
    – ashwin karki
    Nov 11 at 7:41










  • in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
    – ashwin karki
    Nov 11 at 7:42










  • From where that text no data is comming from api or you gave it manually??
    – undefined
    Nov 11 at 7:59










  • No No jquery will detect the no of values and show them automatcially
    – ashwin karki
    Nov 11 at 8:48












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Actaully I have the data that are fetched through api and are being displayed in datatable in angular.I need to show the two tables in same html page so I have used two datatables but in one of those table I get "No data available in table". If i use single table then there is not this problem.



component.ts file



 constructor(private http: HttpClient,private assignmentAuditService: AssignmentAuditService,private selectionService: SelectionService,
private chRef: ChangeDetectorRef, private chRef1: ChangeDetectorRef,
private authService:LoginAuthService,private auditGroupService:AuditGroupService)
this.authService.isLoggedIn();



ngOnInit()

this.http.get('http://localhost:8080/api/auditgroup')
.subscribe((data: any) =>
this.auditorgroups = data;
console.log(this.auditorgroups);
);

//i have called the api to load data into datatable here this.http.get
('http://localhost:8080/api/selections/getAllNonAuditGroupSelections')
.subscribe((data: any) =>
this.clients = data;
console.log(this.clients);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);

/* for auditgroup selecitonm */

//i have called the api to load data into datatable here
this.http.get('http://localhost:8080/api/selections/getAllAuditGroupSelections')
.subscribe((datas: any) =>
this.nonAuditSelection = datas;
console.log(this.nonAuditSelection);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef1.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);




html to display table



<h5>Selection Without Audit Group</h5>
<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let client of clients" (click)="onClick(client)">
<td [ngStyle]="getStyle(this.client)">client.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td [ngStyle]="getStyle(this.client)">client.selectionDate</td>
<td [ngStyle]="getStyle(this.client)">client.selectedBy</td>
<td [ngStyle]="getStyle(this.client)">client.panEximNumber</td>
<td [ngStyle]="getStyle(this.client)">client.name</td>
<td>client.address</td>
<td>client.phoneNumber</td>
<td>client.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>

<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let nonAudit of nonAuditSelection">
<td>nonAudit.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td>nonAudit.selectionDate</td>
<td>nonAudit.selectedBy</td>
<td>nonAudit.panEximNumber</td>
<td>nonAudit.name</td>
<td>nonAudit.address</td>
<td>nonAudit.phoneNumber</td>
<td>nonAudit.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>


Table is diplayed as :



enter image description here



The api datas are coming right as here is no problem :



enter image description here










share|improve this question















Actaully I have the data that are fetched through api and are being displayed in datatable in angular.I need to show the two tables in same html page so I have used two datatables but in one of those table I get "No data available in table". If i use single table then there is not this problem.



component.ts file



 constructor(private http: HttpClient,private assignmentAuditService: AssignmentAuditService,private selectionService: SelectionService,
private chRef: ChangeDetectorRef, private chRef1: ChangeDetectorRef,
private authService:LoginAuthService,private auditGroupService:AuditGroupService)
this.authService.isLoggedIn();



ngOnInit()

this.http.get('http://localhost:8080/api/auditgroup')
.subscribe((data: any) =>
this.auditorgroups = data;
console.log(this.auditorgroups);
);

//i have called the api to load data into datatable here this.http.get
('http://localhost:8080/api/selections/getAllNonAuditGroupSelections')
.subscribe((data: any) =>
this.clients = data;
console.log(this.clients);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);

/* for auditgroup selecitonm */

//i have called the api to load data into datatable here
this.http.get('http://localhost:8080/api/selections/getAllAuditGroupSelections')
.subscribe((datas: any) =>
this.nonAuditSelection = datas;
console.log(this.nonAuditSelection);

// You'll have to wait that changeDetection occurs and projects data into
// the HTML template, you can ask Angular to that for you ;-)
this.chRef1.detectChanges();

// Now you can use jQuery DataTables :
const table: any = $('table');
this.dataTable = table.DataTable();
);




html to display table



<h5>Selection Without Audit Group</h5>
<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let client of clients" (click)="onClick(client)">
<td [ngStyle]="getStyle(this.client)">client.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td [ngStyle]="getStyle(this.client)">client.selectionDate</td>
<td [ngStyle]="getStyle(this.client)">client.selectedBy</td>
<td [ngStyle]="getStyle(this.client)">client.panEximNumber</td>
<td [ngStyle]="getStyle(this.client)">client.name</td>
<td>client.address</td>
<td>client.phoneNumber</td>
<td>client.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>

<div class="card-body">

<div class="col-md-12">
<table class="table table-bodered">

<thead>
<tr>
<th>Selection No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<!-- <th>Action</th> -->

</tr>
</thead>
<tbody>
<tr *ngFor="let nonAudit of nonAuditSelection">
<td>nonAudit.selectionId</td>
<!--*ngIf="!client.auditorGroup" [ngClass]="'myclass2': client.auditorGroup, 'myclass1': !client.auditorGroup"-->
<td>nonAudit.selectionDate</td>
<td>nonAudit.selectedBy</td>
<td>nonAudit.panEximNumber</td>
<td>nonAudit.name</td>
<td>nonAudit.address</td>
<td>nonAudit.phoneNumber</td>
<td>nonAudit.selectionType</td>
<!-- <td *ngIf="!client.auditorGroup" [ngStyle]="getStyle(this.client)">Edit
Delete</td> -->

</tr>


</tbody>

</table>
</div>
</div>


Table is diplayed as :



enter image description here



The api datas are coming right as here is no problem :



enter image description here







javascript angular datatable angular6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 7:25

























asked Nov 11 at 5:56









ashwin karki

1469




1469











  • Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
    – undefined
    Nov 11 at 7:36










  • yes the values coming in two tables are from two different api's
    – ashwin karki
    Nov 11 at 7:41










  • in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
    – ashwin karki
    Nov 11 at 7:42










  • From where that text no data is comming from api or you gave it manually??
    – undefined
    Nov 11 at 7:59










  • No No jquery will detect the no of values and show them automatcially
    – ashwin karki
    Nov 11 at 8:48
















  • Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
    – undefined
    Nov 11 at 7:36










  • yes the values coming in two tables are from two different api's
    – ashwin karki
    Nov 11 at 7:41










  • in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
    – ashwin karki
    Nov 11 at 7:42










  • From where that text no data is comming from api or you gave it manually??
    – undefined
    Nov 11 at 7:59










  • No No jquery will detect the no of values and show them automatcially
    – ashwin karki
    Nov 11 at 8:48















Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
– undefined
Nov 11 at 7:36




Can't get your problem correctly.. As in image we could able to see the two separate datas coming for two tables respectively.. In table one you were getting the values but in addition you are getting the no data available in table right??
– undefined
Nov 11 at 7:36












yes the values coming in two tables are from two different api's
– ashwin karki
Nov 11 at 7:41




yes the values coming in two tables are from two different api's
– ashwin karki
Nov 11 at 7:41












in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
– ashwin karki
Nov 11 at 7:42




in one table it is showing data plus all things properly but where in another table it is showing me no data available in table
– ashwin karki
Nov 11 at 7:42












From where that text no data is comming from api or you gave it manually??
– undefined
Nov 11 at 7:59




From where that text no data is comming from api or you gave it manually??
– undefined
Nov 11 at 7:59












No No jquery will detect the no of values and show them automatcially
– ashwin karki
Nov 11 at 8:48




No No jquery will detect the no of values and show them automatcially
– ashwin karki
Nov 11 at 8:48












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The issue is with the jQuery selector you are using, try this:




  1. Add id to each table as below:



    <table id="table1" class="table table-bodered">



    <table id="table2" class="table table-bodered">




  2. In your .ts change selector as below for the relevant api data to show:



    const table: any = $('#table1');



    const table: any = $('#table2');



Currently, as you are always selecting a table: $('table) jquery selects one table and renders data to it. Hope it helps.






share|improve this answer
















  • 1




    thnk u it worked :)
    – ashwin karki
    Nov 12 at 4:22










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246238%2fdatatable-saying-no-data-available-in-table-even-though-there-is-data-in-the-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










The issue is with the jQuery selector you are using, try this:




  1. Add id to each table as below:



    <table id="table1" class="table table-bodered">



    <table id="table2" class="table table-bodered">




  2. In your .ts change selector as below for the relevant api data to show:



    const table: any = $('#table1');



    const table: any = $('#table2');



Currently, as you are always selecting a table: $('table) jquery selects one table and renders data to it. Hope it helps.






share|improve this answer
















  • 1




    thnk u it worked :)
    – ashwin karki
    Nov 12 at 4:22














up vote
1
down vote



accepted










The issue is with the jQuery selector you are using, try this:




  1. Add id to each table as below:



    <table id="table1" class="table table-bodered">



    <table id="table2" class="table table-bodered">




  2. In your .ts change selector as below for the relevant api data to show:



    const table: any = $('#table1');



    const table: any = $('#table2');



Currently, as you are always selecting a table: $('table) jquery selects one table and renders data to it. Hope it helps.






share|improve this answer
















  • 1




    thnk u it worked :)
    – ashwin karki
    Nov 12 at 4:22












up vote
1
down vote



accepted







up vote
1
down vote



accepted






The issue is with the jQuery selector you are using, try this:




  1. Add id to each table as below:



    <table id="table1" class="table table-bodered">



    <table id="table2" class="table table-bodered">




  2. In your .ts change selector as below for the relevant api data to show:



    const table: any = $('#table1');



    const table: any = $('#table2');



Currently, as you are always selecting a table: $('table) jquery selects one table and renders data to it. Hope it helps.






share|improve this answer












The issue is with the jQuery selector you are using, try this:




  1. Add id to each table as below:



    <table id="table1" class="table table-bodered">



    <table id="table2" class="table table-bodered">




  2. In your .ts change selector as below for the relevant api data to show:



    const table: any = $('#table1');



    const table: any = $('#table2');



Currently, as you are always selecting a table: $('table) jquery selects one table and renders data to it. Hope it helps.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 12:07









User3250

1,5433825




1,5433825







  • 1




    thnk u it worked :)
    – ashwin karki
    Nov 12 at 4:22












  • 1




    thnk u it worked :)
    – ashwin karki
    Nov 12 at 4:22







1




1




thnk u it worked :)
– ashwin karki
Nov 12 at 4:22




thnk u it worked :)
– ashwin karki
Nov 12 at 4:22

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246238%2fdatatable-saying-no-data-available-in-table-even-though-there-is-data-in-the-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3