Is there any way of creating an empty row in PrimeNG table? When all rows are filled with data, the amount of rows shrink, but I want to have always visible 6 rows. If no data is available then they should be empty.
2 Answers
You can just add on ngOnInit()
the array this.array = new Array<array>();
. Then create an object of that class, like: this.arrayValue = new array()
and push it to the array. this.array.push(this.arrayValue)
. On your http call you just need to add an IF like if(data.length==0)....
and then do this. And you ll have and empty row even if it returns no data.

- 148
- 1
- 10
I managed to solve my problem. I could not find any propper attribute in p-table so in order to fill table with empty rows I pushed empty objects through transformation in pipe, using modulo to precize how many of them to add and it worked. I know that this is not a great solution because you need to pass fake data to your model but it is a workaround. At the end I just made fixed height on table, added white background and border-bottom line after last record. Such approach was accepted by our designer and didn't require to put fake data to model. I hope it helps.

- 1
- 3