我有一个问题,我使用外键字段的下拉列表,如demo:http://demos.kendoui.com/web/grid/foreignkeycolumn.html
区别在于我的模型中的foreignkey字段如果与其他任何人无关,则可以为null。然后我的问题是当我尝试使用这个foreignkey字段的editRow时,原始值为null,并且我想要更改为另一个值,此字段将始终获取值'[object object]'。我不知道为什么。
请参阅以下代码中的楼层字段:
<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>
感谢。