要求:如何在更新记录时获取剑道网格中的选定下拉值
通过使用kendo编辑器,我在网格列中实现了下拉列表,我想保存datavaluefiled值
数据源 ID:1,Interestname:蟋蟀 ID:2,Interestname:足球 在submiiting我需要只保存值i:e Id
export class App implements OnInit, AfterViewInit, AfterContentInit {
@Input() myInput: string;
@ViewChild() myTemplate: TemplateRef<any>;
@ContentChild(ChildComponent) myComponent: ChildComponent;
constructor(private elementRef: ElementRef) {
// this.elementRef.nativeElement is undefined here
// this.myInput is undefined here
// this.myTemplate is undefined here
// this.myComponent is undefine here
}
ngOnInit() {
// this.elementRef.nativeElement can be used from here on
// value of this.myInput is passed from parent scope
// this.myTemplate and this.myComponent are still undefined
}
ngAfterContentInit() {
// this.myComponent now gets projected in and can be accessed
// this.myTemplate is still undefined
}
ngAfterViewInit() {
// this.myTemplate can be used now as well
}
}
答案 0 :(得分:1)
我认为您可能会绑定模型上的错误属性。另外,请尝试将下拉列表的valuePrimitive属性设置为true
:
$('<input required data-bind="value:' + options.field + '" name="' + options.field + '" id="dropintrest" onchange="drop(this)"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField:"InterestName",
dataValueField:"Id",
dataSource: dropDownDataSource,
valuePrimitive: true
});
根据文件:
如果设置为true,将使用所选项目值字段更新View-Model字段。如果设置为false,则将使用所选项目更新View-Model字段。
希望这有帮助。