尝试动态呈现表单时,Nativescript UI rad dataform 的行为非常奇怪



我正在尝试构建一个清单应用程序,其中清单由许多部分组成,每个部分由许多任务组成。 我正在使用Nativescript UI-dataform来呈现表单,因为这些表单是由REST API动态生成的JSON模型。 我创建了一个分页器,用于在当前活动 JSON 模型的模板中设置上一个或下一个任务,并在数据表单的 [源和 [元数据输入。 当我点击上一个或下一个 V 形时,视图会按预期更改,并且数据表单会更新。 当我向前移动至少两个任务,然后点击左 V 形(上一个任务页面图标)时,似乎会出现问题。 然后,由于某种原因,表单在文本编辑器中显示任务,而不是在元数据模型上显式设置的开关,然后我收到以下错误。 我的代码低于错误。 知道这里可能出了什么问题/我该如何解决这个问题吗? 我已经尝试了所有其他方法,但没有任何成功,并且在进行Google搜索时看不到任何相关内容... 从错误来看,问题似乎是 rad dataform 尝试使用应该使用布尔开关编辑器的文本编辑器?

my error:
JS: ERROR Error: java.lang.Error: DataFormTextEditor does not support properties of type Boolean. Please specify a value converter for your property.
JS:     com.telerik.widget.dataform.visualization.core.EntityPropertyViewer.loadPropertyValue(EntityPropertyViewer.java:430)
JS:     com.telerik.widget.dataform.visualization.core.EntityPropertyEditor.loadPropertyValue(EntityPropertyEditor.java:201)
JS:     com.telerik.widget.dataform.visualization.core.EntityPropertyViewer.load(EntityPropertyViewer.java:409)
JS:     com.telerik.widget.dataform.visualization.core.EntityPropertyEditor.load(EntityPropertyEditor.java:189)
JS:     com.telerik.widget.dataform.visualization.RadDataForm.load(RadDataForm.java:806)
JS:     com.telerik.widget.dataform.visualization.RadDataForm.reload(RadDataForm.java:485)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
...

my code:
my xml view code:
<ActionBar title="Dynamic Forms POC" class="action-bar">
</ActionBar>
<StackLayout>
<StackLayout class="m-x-auto m-b-30 p-t-20" orientation="horizontal">
<Label (tap)="prevTask()" class="font-awesome p-t-4 p-r-10" text="&#xf053;"></Label>
<Label class="p-b-5" [text]="'Task ' + displayTaskNo() + ' / ' + currentForm.sections[sectionID].tasks.length"></Label>
<Label (tap)="nextTask()" class="font-awesome p-t-4 p-l-10" text="&#xf054;"></Label>
</StackLayout>
<StackLayout> 
<RadDataForm #rdf  [source]="currentForm?.sections[sectionID].tasks[taskID].template" [metadata]="currentForm?.sections[sectionID].tasks[taskID].metadata" (propertyCommitted)="onPropertyCommitted()"></RadDataForm>    
</StackLayout>
</StackLayout>
my prevTask() and nextTask() functions:
prevTask() {
if (this.taskID === 0) {
return;
}
this.taskID--;        
}
nextTask() {
console.log(this.currentForm.sections[this.sectionID].tasks[this.taskID-1]);
if (this.taskID === this.currentForm.sections[this.sectionID].tasks.length - 1) {
return;
}
this.taskID++;
}

a example json model:
{
"name": "Form1",
"sections": [
{
"secName": "Food Safety Criticals",
"tasks": [
{
"taskName": "Restaurant free of insects / pests",
"imageNames": [],
"template": {
"RestaurantShouldBeFreeOfAllInsectsOrPests": false
},
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [
{              
"name": "RestaurantShouldBeFreeOfAllInsectsOrPests",
"displayName": "Restaurant should be free of all insects or pests",
"index": 0,
"editor":"Switch"
}
]
}
},
{
"taskName": "only approved ingredients or food evident",
"imageNames": [],
"template": {
"Onlyapprovedingredientsorfoodevident": false
},          
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [
{
"name": "Onlyapprovedingredientsorfoodevident",
"displayName": "only approved ingredients or food evident",
"index": 0,
"editor":"Switch"
}
]
}        
},
{
"taskName": "Restaurant must have hot water at all times",
"imageNames": [],
"template": {
"Restaurantmusthavehotwateratalltimes": false
},
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [   
{
"name": "Restaurantmusthavehotwateratalltimes",
"displayName": "Restaurant must have hot water at all times",
"index": 0,
"editor": "Switch"
}
]
}
},
{
"taskName": "Spoiled potentially hazardous foods / ingredients are not in use and not for sale",
"imageNames": [],
"template": {
"Spoiledpotentiallyhazardousfoods/ingredientsarenotinuseandnotforsale": false
},
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [
{
"name": "Spoiledpotentiallyhazardousfoods/ingredientsarenotinuseandnotforsale",
"displayName": "Spoiled potentially hazardous food / ingredients are not in use and not for sale",
"index": 0,
"editor": "Switch"
}
]
}
},
{
"taskName": "Cross-Contamination is not observed",
"imageNames": [],
"template": {
"Cross-Contaminationisnotobserved": false
},
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [
{
"name": "Cross-Contaminationisnotobserved",
"displayName": "Cross-Contamination is not observed",
"index": 0,
"editor": "Switch"
}
]        
}
},
{
"taskName": "ColdpotentiallyHazardousFoodsmustbeheld4°Candwithinholdtimesperbrandstandards",
"imageNames": [],      
"template": {    
"ColdpotentiallyHazardousFoodsmustbeheld4°Candwithinholdtimesperbrandstandards": false
},
"metadata": {
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "Immediate",
"propertyAnnotations": [                     
{
"name": "ColdpotentiallyHazardousFoodsmustbeheld4°Candwithinholdtimesperbrandstandards",
"displayName": "Cold potentially Hazardous Foods must be held 4°C and within hold times per brand standards",
"index": 0,
"editor": "Switch"
}
]
}
}
]  
}
]
}

所以事实证明,当我在控制器中更改"任务"索引时,Rad Dataform 选择了表单源的更改,但没有选择元数据的更改...... 我为解决此问题所做的是:每当我导航到上一个/下一个任务时,手动设置表单元数据......

最新更新