我有這是在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