Is there a way to display a list of objects in a single table cell for ng2-smart-table? I have tried creating a renderComponent but I am getting an empty value. Another question is will the filtering and sorting still work for this?
Asked
Active
Viewed 1,701 times
0
-
Can you show me what is your expected result ? – Sachin Shah Nov 15 '18 at 03:18
1 Answers
0
As I understood , You have a object and you want to display that data in ng2-smart-table
.
For that follow this step.
import { LocalDataSource } from 'ng2-smart-table';
source : any = LocalDataSource;
When you call API then you have to set that data in source.
this.apiService.POST({}, 'getProductList').subscribe((res) => {
console.log(res);
this.source = new LocalDataSource(res.data); // Set response as per your res.
});
As you can see I have also set one array and that array has objects of data and I have set in table.
I hope this may help you. :)

Sachin Shah
- 4,503
- 3
- 23
- 50
-
My problem is when there is nested list of object withing the list. For example, – Chong We Tan Nov 16 '18 at 03:26
-
-
-
1My problem is when there is a nested list of object. For example, { cgst: 5, company_id: 1, product:[{ product_id: 1, product_name: "Laptop" },{ product_id: 2, product_name: "PC" }] } – Chong We Tan Nov 16 '18 at 05:57
-
@ChongWeTan As I have add comment in answer set res per your res. In your given example, You have to just set `this.source = new LocalDataSource(res.data.product)` – Sachin Shah Nov 16 '18 at 06:26
-
Can you try this data: { cgst: 5, company_id: 1, product:[{ product_id: 1, product_name: "Laptop" },{ product_id: 2, product_name: "PC" }] } – Chong We Tan Nov 16 '18 at 10:39
-
@ChongWeTan Do you want to show the data cgst and company_id also in table ? – Sachin Shah Nov 16 '18 at 10:42
-
Yes, for example, the table header will be cgst, company id, product id, product name, then the content will be the corresponding, 5, 1, 1 and 2(same row), Laptop and PC (same row) – Chong We Tan Nov 19 '18 at 05:05
-
@ChongWeTan You can set object data in variable. Which you get on chage event also. For that you don't need to display in table. For example in object you can set 10 data but in page you can show only required data. :) – Sachin Shah Nov 19 '18 at 05:28
-