Kendo ui 外键字段get';[对象对象]';具有原始字段值的editRow为空时的值
我有一个问题,我使用了一个下拉列表作为我的外键字段,比如demo: 不同之处在于,我的模型中的foreignkey字段在与其他任何人无关的情况下,有时可能会为null。然后,我的问题是,当我尝试使用此foreignkey字段的原始值为null编辑行,并且我想更改为另一个值时,此字段将始终获得值“[object]”。我不知道为什么 请参见以下代码中的楼层字段:Kendo ui 外键字段get';[对象对象]';具有原始字段值的editRow为空时的值,kendo-ui,Kendo Ui,我有一个问题,我使用了一个下拉列表作为我的外键字段,比如demo: 不同之处在于,我的模型中的foreignkey字段在与其他任何人无关的情况下,有时可能会为null。然后,我的问题是,当我尝试使用此foreignkey字段的原始值为null编辑行,并且我想更改为另一个值时,此字段将始终获得值“[object]”。我不知道为什么 请参见以下代码中的楼层字段: <script> $(document).ready(function() { var templat
<script>
$(document).ready(function() {
var template = kendo.template($("#detail_template").html());
function show_menu_details(menuObj) {
var tg = $("#details");
tg.fadeOut(function(){
tg.html(template(menuObj));
tw = tg.find(".k-window");
tw.css({width:tg.innerWidth()-30, height:tg.innerHeight()-55, "margin-top": 20, "margin-left":15});
});
tg.fadeIn();
}
$("#horizontal").kendoSplitter({
panes: [{collapsible: true, size: "180px"},
{ collapsible: true} ],
height: 690
});
function onChange(e){
e.preventDefault();
selectedObj = this.dataSource.getByUid(this.select().data('uid'))
//console.log(selectedObj);//(this.dataSource.data());
show_menu_details(selectedObj);
}
var statuses = [
{value:'', text:'--'},
{value:'Available', text:'Available'},
{value:'Locked', text:'Locked'},
{value:'Reserved', text:'Reserved'},
{value:'Occupied', text:'Occupied'}];
var floors = new Array();
floors[0]={text:'--',value:''};
_DS_Floor.fetch(function(data){
$.each(data.items,function(index,obj){
floors[index+1] = {text: obj.name, value: obj.id};
});
var grid = $("#list").kendoGrid({
dataSource: _DS_Room,
selectable: "row",
filterable: true,
columnMenu: true,
pageable: {refresh:true},
editable: {mode:"popup",confirmation:"Sure to delete?"},
height: 688,
scrollable: {
virtual: true
},
sortable: true,
toolbar: kendo.template($("#toolbar_template").html()),
columns: [//{field:'id',title:' ',width:40,template: '<input type="checkbox" id="#= id #" />'},
{field:'name',title:'Name'},
{field:'floor',title:'Floor',values:floors},
{field:'position',title:'Position'},
{field:'status',title:'Status',width:80,values:statuses}],//_Columns_Menu,//{ command: ['edit','destroy'], title: "", width: "200px" }
//change: onChange
});
grid.find("#btn-add").click(function(e){
e.preventDefault();
grid.data("kendoGrid").addRow();
});
grid.find("#btn-save").click(function(e){
e.preventDefault();
grid.data("kendoGrid").saveChanges();//editRow(grid.data("kendoGrid").select());
});
grid.find("#btn-remove").click(function(e){
e.preventDefault();
grid.data("kendoGrid").removeRow(grid.data("kendoGrid").select());
});
grid.find("#btn-cancel").click(function(e){
e.preventDefault();
grid.data("kendoGrid").cancelChanges();//removeRow(grid.data("kendoGrid").select());
});
});
});
</script>
$(文档).ready(函数(){
var template=kendo.template($(“#细节_template”).html();
功能显示菜单详细信息(menuObj){
var tg=$(“详细信息”);
tg.fadeOut(函数(){
html(模板(menuObj));
tw=tg.find(“.k-window”);
css({width:tg.innerWidth()-30,height:tg.innerHeight()-55,“页边顶部”:20,“页边左侧”:15});
});
tg.fadeIn();
}
$(“#水平”).kendospliter({
窗格:[{可折叠:true,大小:“180px”},
{可折叠:true}],
身高:690
});
函数onChange(e){
e、 预防默认值();
selectedObj=this.dataSource.getByUid(this.select().data('uid'))
//console.log(selectedObj);/(this.dataSource.data());
显示菜单详细信息(选择BJ);
}
变量状态=[
{值:“”,文本:'--'},
{值:'Available',文本:'Available'},
{值:'Locked',文本:'Locked'},
{值:'Reserved',文本:'Reserved'},
{值:'occulated',文本:'occulated'}];
var floors=新数组();
楼层[0]={text:'--',值:'};
_DS_Floor.fetch(函数(数据){
$.each(数据项、函数(索引、obj){
楼层[index+1]={text:obj.name,value:obj.id};
});
变量网格=$(“#列表”).kendoGrid({
数据源:_DS_房间,
可选:“行”,
可过滤:正确,
专栏菜单:是的,
可分页:{refresh:true},
可编辑:{模式:“弹出”,确认:“确定删除?”},
身高:688,
可滚动:{
虚拟的:真的
},
可排序:是的,
工具栏:kendo.template($(“#toolbar_template”).html(),
列:[/{字段:'id',标题:'',宽度:40,模板:'},
{字段:'name',标题:'name'},
{字段:'floor',标题:'floor',值:floors},
{字段:'position',标题:'position'},
{field:'status',title:'status',width:80,value:statuses}],//{u Columns\ u菜单,//{command:['edit','destroy'],title:,width:'200px}
//更改:onChange
});
网格。查找(“#btn添加”)。单击(函数(e){
e、 预防默认值();
grid.data(“kendoGrid”).addRow();
});
网格。查找(“#btn保存”)。单击(函数(e){
e、 预防默认值();
grid.data(“kendoGrid”).saveChanges();//editRow(grid.data(“kendoGrid”).select());
});
网格。查找(“#btn删除”)。单击(函数(e){
e、 预防默认值();
grid.data(“kendoGrid”).removeow(grid.data(“kendoGrid”).select());
});
网格。查找(“#btn取消”)。单击(函数(e){
e、 预防默认值();
grid.data(“kendoGrid”).cancelChanges();//removeRow(grid.data(“kendoGrid”).select());
});
});
});
谢谢。不支持可为空的值。这是来自KendoUI论坛的问题,Vladimir Iliev对此提供了解释和解决方案。我希望这能有所帮助。2017年的情况仍然如此吗?不支持null似乎有点疯狂,解决方案是一种黑客攻击。