我正在页面上创建一个radListView数组,对于每个radList,我实现一个“ radListView.itemTemplates”,如下所示:
radListView.itemTemplates = [
{
key: "notaBaixa",
createView: () => {
const gridLayout = new GridLayout();
gridLayout.addColumn(new ItemSpec(1, GridUnitType.STAR));
gridLayout.addColumn(new ItemSpec(1, GridUnitType.AUTO));
gridLayout.addColumn(new ItemSpec(1, GridUnitType.AUTO));
gridLayout.verticalAlignment = "middle";
gridLayout.css = "border-bottom-width:1px; border-bottom-color:black;";
const lblDisciplina = new Label();
lblDisciplina.col = 0;
lblDisciplina.setInlineStyle("padding:10px 0 0 10px; height:60px;");
lblDisciplina.verticalAlignment = "middle";
lblDisciplina.text = "{{disciplina}}";
const lblnotaTotal = new Label();
lblnotaTotal.col = 1;
lblnotaTotal.setInlineStyle("padding:10px 0 0 10px; height:60px; color: red;");
lblnotaTotal.verticalAlignment = "middle";
lblnotaTotal.text = "{{nota_total}}";
const lblFaltasTotal = new Label();
lblFaltasTotal.col = 2;
lblFaltasTotal.setInlineStyle("padding:10px 0 0 10px; height:60px;");
lblFaltasTotal.verticalAlignment = "middle";
lblFaltasTotal.text = "{{faltas_total}}";
gridLayout.addChild(lblDisciplina);
gridLayout.addChild(lblnotaTotal);
gridLayout.addChild(lblFaltasTotal);
return gridLayout;
}
},
{
key: "notaAlta",
createView: () => {
const gridLayout = new GridLayout();
gridLayout.addColumn(new ItemSpec(1, GridUnitType.STAR));
gridLayout.addColumn(new ItemSpec(1, GridUnitType.AUTO));
gridLayout.addColumn(new ItemSpec(1, GridUnitType.AUTO));
gridLayout.verticalAlignment = "middle";
gridLayout.css = "border-bottom-width:1px; border-bottom-color:black;";
const lblDisciplina = new Label();
lblDisciplina.col = 0;
lblDisciplina.setInlineStyle("padding:10px 0 0 10px; height:60px;");
lblDisciplina.verticalAlignment = "middle";
lblDisciplina.text = "{{disciplina}}";
const lblnotaTotal = new Label();
lblnotaTotal.col = 1;
lblnotaTotal.setInlineStyle("padding:10px 0 0 10px; height:60px; color: blue;");
lblnotaTotal.verticalAlignment = "middle";
lblnotaTotal.text = "{{nota_total}}";
const lblFaltasTotal = new Label();
lblFaltasTotal.col = 2;
lblFaltasTotal.setInlineStyle("padding:10px 0 0 10px; height:60px;");
lblFaltasTotal.verticalAlignment = "middle";
lblFaltasTotal.text = "{{faltas_total}}";
gridLayout.addChild(lblDisciplina);
gridLayout.addChild(lblnotaTotal);
gridLayout.addChild(lblFaltasTotal);
return gridLayout;
}
}
];
如您所见,在我的标签中,我试图获取源项目的某些属性,但标签不理解为属性。如何将标签文本值设置为项目来源属性?
答案 0 :(得分:0)
请参阅data binding docs。您使用的语法仅在XML上有效,XML解析器将解释该语法并启动元素与数据模型之间的绑定。
您必须在目标元素上调用bind
方法,并传递source&target属性以编程方式执行同样的操作。
例如,
lblDisciplina.text = "{{disciplina}}";
应该是
lblDisciplina.bind({
sourceProperty: "disciplina",
targetProperty: "text",
twoWay: false
});