javascript - oj-select-one 显示未定义的所有选项
问题描述
我有一个可观察的数组,它从 REST 中获取它的值
$.getJSON(rootModel.soho()).
then(function (StudentCourseView1) {
$.each(StudentCourseView1.items, function () {
self.data.push({
StudentId: this.StudentId,
CourseId: this.CourseId,
Enrollmentdate :this.Enrollmentdate,
Notes :this.Notes,
Id : this.Id,
CourseName : this.CourseName,
StudentName: this.StudentName
});
});
});
self.dataSource = new oj.ArrayTableDataSource(
self.data,
{idAttribute: 'Id'}
);
我已经创建了这样的选择
<oj-select-one id="select1" style="max-width:20em"
options={{data}}
value="{{data.Id}}"
options-keys="[[data.StudentName]]" >
</oj-select-one>
选择一个显示未定义的所有它选项
解决方案
您确定 ajax 调用正在工作,并且控制台中没有错误吗?下拉菜单是否显示空白值列表?
如果是,那么唯一缺少的元素是添加option-keys
属性,以解释要向用户显示哪些数据,以及每条数据的键。
<oj-select-one id="select1" style="max-width:20em"
options={{data}}
options-keys="{{optionKeys}}"
value="{{StudentId}}">
JS
//You can change this acc. to your convenience.
self.optionKeys = {value:"Id", label:"StudentName"};
推荐阅读
- excel - 根据 3x 单元格 EXCEL 的标准更改行颜色
- sql-server - 如果未在 SSIS 服务器内执行,SSIS 包将失败
- python - Raspberry Pi 4,Open CV 错误:V4L2:OpenCV 不支持传入图像的像素格式
- python - 如何确定图像是图像的图像还是真实 3d 对象的图像?
- java - 使用 java 的 Android Studio 中的 JDBC 连接
- vue.js - 如何在新标签页中打开当前会话?
- netty - 为请求类型配置 ReadTimeoutHandler 或 WriteTimeoutHandler
- jupyter-notebook - 带有熊猫错误的jupyter笔记本重新索引
- path - 如何防止我的网址被重置?
- javascript - 如何在 Vue 2 的响应式对象中存储值映射?