简体   繁体   English

无法在TRIRIGA的Iron-ajax中填充表中的数据

[英]not able to populate data in table in iron-ajax in TRIRIGA

I am facing problem in populating data in triblock-table using iron-ajax. 我在使用iron-ajax填充triblock-table中的数据时遇到问题。

I have my empleelist.json file in the same folder where .html file. 我的empleelist.json文件与.html文件位于同一文件夹中。 Moreover, When I debug it and then I found URL : 而且,当我调试它时,我发现了URL:

http://XXXX:port/p/components/r/en-US/l/tut-people/employeelist.json and after this, I am getting the value as json. http:// XXXX:port / p / components / r / en-US / l / tut-people / employeelist.json之后,我得到的值为json。

I am calling it as: 我称它为:

<link rel="import" href="../triblock-table/triblock-table.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-item/paper-icon-item.html">
<link rel="import" href="../paper-item/paper-item-body.html">



<dom-module id="tut-person">
<style is="custom-style">
  #table1 {
    color: white;
    --triblock-table-header-background-color: violet;
    --triblock-table-header-color: green;
    --triblock-table-even-row-background-color: rgb(80, 80, 80);
    --triblock-table-odd-row-background-color: rgb(40, 40, 40);
    --triblock-table-row-hover-background-color: darkblue;
  }
</style>
<template>
<h1>Table Layout</h1>
<iron-ajax url="employeelist.json" handle-as="json" last-response="{{employees}}"  content-type="application/json" auto></iron-ajax>

<triblock-table id="table1"  data="{{employees}}" style="width:100%; height:250px;">
    <triblock-table-column title="Employee ID" property="id"></triblock-table-column>
  <triblock-table-column title="Name" property="Name"></triblock-table-column>
  <triblock-table-column title="First Name" property="First Name"></triblock-table-column>
  <triblock-table-column title="Last Name" property="Last Name"></triblock-table-column>
  <triblock-table-column title="Status" property="Status"></triblock-table-column>
</triblock-table>
</template>

</dom-module>
<script>
Polymer({

is: "tut-person",
behaviors: [TriPlatViewBehavior]
});

</script>

However, I am not able to populate data in the table. 但是,我无法在表中填充数据。

JSON file: JSON文件:

[
    {
"id":123456
"Name":"Kumar Shorav"
"First Name":"Kumar"
"LastName":"Shorav"
"Status":"Active"
    },
{
"id":12346
"Name":"Kumar Shorav1"
"First Name":"Kumar1"
"LastName":"Shorav1"
"Status":"Active"
    }
]

I was able to fix this. 我能够解决这个问题。 This was because json string was null. 这是因为json字符串为null。 In turn, last-response variable was set to null so I was getting no response on screen. 反过来,last-response变量设置为null,所以我在屏幕上没有任何响应。 After correcting Json string, this was working. 更正Json字符串后,此方法有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM