Base solution for your next web application
Open Closed

Cannot Display Data on P-Table #7875


User avatar
0
sophoana created

Hi support

Cannot Display Data on P-Table

HTML file:

<p-table

                                                [value]=&quot;itemPrice&quot;
                                                [loading]=&quot;loading&quot;
                                                [responsive]=&quot;primengTableHelper.isResponsive&quot;&gt;
                                                &lt;ng-template pTemplate=&quot;header&quot;&gt;
                                                    &lt;tr&gt;                                                            
                                                        &lt;th style=&quot;width: 100px&quot;&gt;{{'Actions' | localize}}&lt;/th&gt;
                                                        &lt;th pSortableColumn=&quot;unitMeasureName&quot;&gt;
                                                            {{'UnitMeasure' | localize}}
                                                            &lt;p-sortIcon field=&quot;unitMeasureName&quot;&gt;&lt;/p-sortIcon&gt;
                                                        &lt;/th&gt;
                                                        &lt;th pSortableColumn=&quot;price&quot;&gt;
                                                            {{'Price' | localize}}
                                                            &lt;p-sortIcon field=&quot;price&quot;&gt;&lt;/p-sortIcon&gt;
                                                        &lt;/th&gt;
                                                    &lt;/tr&gt;
                                                &lt;/ng-template&gt;
                                                &lt;ng-template pTemplate=&quot;body&quot; let-record=&quot;$implicit&quot;&gt;
                                                    &lt;tr&gt;                                                            
                                                        &lt;td style=&quot;width: 130px&quot;
                                                            [hidden]=&quot;!isGrantedAny(&#39;Pages.Items.Edit&#39;, &#39;Pages.Items.Delete&#39;)&quot;&gt;
                                                            &lt;div class=&quot;btn-group dropdown&quot; dropdown container=&quot;body&quot;&gt;
                                                                &lt;button dropdownToggle class=&quot;dropdown-toggle btn btn-sm btn-primary&quot;&gt;
                                                                    &lt;i class=&quot;fa fa-cog&quot;&gt;&lt;/i&gt;&lt;span class=&quot;caret&quot;&gt;&lt;/span&gt; {{"Actions" | localize}}
                                                                &lt;/button&gt;
                                                                &lt;ul class=&quot;dropdown-menu&quot; *dropdownMenu&gt;                                                
                                                                    &lt;li&gt;
                                                                        &lt;a href=&quot;javascript:;&quot; *ngIf=&quot;&#39;Pages.Items.Edit&#39; | permission&quot;
                                                                        (click)=&quot;deleteItems(record)&quot;&gt;{{'Edit' | localize}}&lt;/a&gt;
                                                                    &lt;/li&gt;
                                                                    &lt;li&gt;
                                                                        &lt;a href=&quot;javascript:;&quot; *ngIf=&quot;&#39;Pages.Items.Delete&#39; | permission&quot;
                                                                        (click)=&quot;deleteItems(record)&quot;&gt;{{'Delete' | localize}}&lt;/a&gt;
                                                                    &lt;/li&gt;
                                                                &lt;/ul&gt;
                                                            &lt;/div&gt;
                                                        &lt;/td&gt;
                                                        &lt;td&gt;
                                                            &lt;span class=&quot;ui-column-title&quot;&gt;{{'UnitMeasure' | localize}}&lt;/span&gt;
                                                            &lt;span title=&quot;{{record.unitMeasureName}}&quot;&gt;&lt;/span&gt;
                                                        &lt;/td&gt;
                                                        &lt;td&gt;
                                                            &lt;span class=&quot;ui-column-title&quot;&gt;{{'Price' | localize}}&lt;/span&gt;
                                                            &lt;span title=&quot;{{record.price}}&quot;&gt;&lt;/span&gt;
                                                        &lt;/td&gt;
                                                    &lt;/tr&gt;
                                                &lt;/ng-template&gt;
                                            &lt;/p-table&gt;

3 Answer(s)
  • User Avatar
    0
    sophoana created

    TS file:

    
    onSelectedUnitMeasurePrice(): void {
          let selectedUnitMeasurePrice = new Array<NameValueOfString>();
          selectedUnitMeasurePrice.push(this.unitMeasurePrice);
          this._unitMeasureServiceProxy.sendAndGetSelectedUnitMeasures(selectedUnitMeasurePrice)
              .subscribe((ChartAccount: NameValueOfString[]) => {              
                  _.forEach(ChartAccount, item => {                  
                      this.itemPrice.push(new ItemPricesEditDto({price: this.priceValue, unitMeasureId: parseInt(item.value), unitMeasureName: item.name, id: 0}));
                      this.primengTableHelper.totalRecordsCount = this.itemPrice.length;                  
                      this.primengTableHelper.records = this.itemPrice;
                      this.priceValue = null;
                      this.unitMeasurePrice = null;
                  });
              });
      }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    On your table definition you must use [value]="primengTableHelper.records" instead of [value]="itemPrice"

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.