我有这是在JS创建一个剑道网格。这个代码不是我的,而是别人的,我真的不认为我们应该改变它的许多基础。但是,其中有一列,我们希望始终显示为下拉框,或者至少看起来像一个。代码如下:剑道网 - 做一个栏始终显示为下拉框
self.caGridOptions = {
widget: self.caKendoGrid,
data: undefined,
dataSource: {
schema: {
model: {
fields: {
id: { type: "number" },
description: { type: "string", editable: false },
value: { type: "number", editable: false },
caTypeDescription: { type: "string", editable: false }
}
}
},
autoSync: true
},
sortable: true,
scrollable: false,
editable: true,
columns: [
{ field: "id", title: "Code", width: 90, template: "#=pager.activePage$().ctx.getca ? pager.activePage$().ctx.getca(id, 'code') : id #", editor: self.caDropDownEditor },
{ field: "description", title: "Description", width: 90, template: "#=pager.activePage$().ctx.getca ? pager.activePage$().ctx.getca(id, 'description') : id #" },
{ field: "value", title: "Value", width: 90, format: "{0:n2}", template: "#=pager.activePage$().ctx.getca ? pager.activePage$().ctx.getca(id, 'value') : id #" },
{ field: "caTypeDescription", title: "Type", width: 90, template: "#=pager.activePage$().ctx.getca ? pager.activePage$().ctx.getca(id, 'caTypeDescription') : id #" },
{ width: 90, filterable: false, template: kendo.template('<a class="btn btn-danger btn-sm" title="delete"><i class="fa fa-trash-o fa-fw" aria-hidden="true"></i> Delete</a>') }
],
dataBound: self.gridButtons,
noRecords: true,
messages: {
noRecords: "There is no data available"
}
};
//
// functions
self.getca = function (id, type) {
if (id == null) return null;
return self.caOptions().filter(function (item) { return item.id == id; })[0][type];
};
编辑时,ID字段(第一列)进入下拉框,如您所见。但是,我们希望这会始终显示为下拉框。不一定总是拥有编辑器(我相信这是不可能的,因为Kendo只能一次将编辑器打开),但也许只需简单地将其格式化为下拉菜单即可。
任何帮助将不胜感激。这很烦人,因为这是一个很小的,小的事情,我们已经得到了其他地方工作的这样的例子,但他们已在CSHTML主要写网格(使用MVC剑道,我认为),我真的不希望重写整个网格中的东西如此微不足道,以及可能依赖于其数据的任何其他功能。
可惜只是一个向下的箭头是不够的(和我们使用相同的图标,我只是想你的代码,它没有工作,我不认为)。我现在正在尝试重新编写网格,因为客户非常热衷于此。 – user25730
查看具体示例的更新。 –
谢谢 - 最终设法使它工作,使用大量的跨度和弄乱填充/边距。 – user25730