首页 文章

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

提问于
浏览
0

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

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"
              }
            ]
          }
        }
      ]  
    }
  ]
}

1 回答

  • 0

    所以事实证明,当我更改了控制器中的“任务”索引时,Rad Dataform获取了表单源的更改而不是元数据...我解决此问题的方法是:每当我导航到上一个/下一个任务时手动设置表单元数据...

相关问题