我的剑道网格中有一个外键,我为这个外键创建了一个编辑器。它在保存时工作正常,但问题是当网格显示数据时,外键值未定义。我知道我必须更改模板才能显示正确的值。我添加了intemplate显示正确值的功能,但它对我不起作用。
你能帮我吗?这是我的代码:
var collection;
$("#mygrid").kendoGrid({
dataSource: dataSource,
pageable: true,
toolbar: [{ name: 'create', text: 'My create' }],
columns: [
{ field: "ForeignKeyColumn", editor: categoryDropDownEditor, template: "#=getTextByValue(data)#" },
{ field: "NOTES", title: "Notes" },
{ command: ["edit", "destroy"], title: " ", width: "160px" }],
editable: "popup",
});
//update model when choose value from dropdown list
var grid = $("#mygrid").data("kendoGrid");
grid.bind("save", grid_save);
function grid_save(e) {
if (e.model.ForeignKey) {
//change the model value
e.model.ForeignKeyColumn = 0;
//get the currently selected value from …Run Code Online (Sandbox Code Playgroud) 我使用的是 Kendo UI Web Grid,而不是服务器包装器之一。我只在网格中显示几个字段。其余字段显示在创建或编辑弹出窗口中。对于这个弹出窗口,我使用了一个模板:
<script id="popup_editor" type="text/x-kendo-template">
<div class="k-edit-label">
<label for="Title">Title</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox" name="Title" data-bind="value:Title" required>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
然后我从网格中调用它:
editable: {
mode: "popup",
template: $("#popup_editor").html(),
confirmation: "Are you sure?"
}
Run Code Online (Sandbox Code Playgroud)
这对输入框很有用。但是我的表中有一个外键列。我想在下拉列表中显示外键表中的所有选项,并根据表中的值选择正确的选项。我已经搜索了很多,但无法找到答案。
任何帮助将不胜感激。
javascript jquery html-select foreign-key-relationship kendo-grid
我正在尝试使用JSFIDDLE 中显示的这个例子,我遇到的问题是我想在放下时挤压新记录而不是交换。我尝试在 drop 函数中添加一个 for 循环,如果目标小于目标记录,则增加目标记录,如果目标大于目标,则减少它。
问题是我最终得到了重复的位置,如 4,4 或 5,5,5。是否有任何剑道 UI 示例可以与此功能一起使用?而不是交换?。
例子:
id text position
1 world 1
2 cup 2
3 Brazil 3
4 2014 4
5 Soccer 5
Run Code Online (Sandbox Code Playgroud)
如果我将记录 4 移到顶部,我想
id text position
4 2014 1
1 World 2
2 Cup 3
3 Brazil 4
5 Soccer 5
Run Code Online (Sandbox Code Playgroud)
如果有人能指出我正确的方向,我将不胜感激。
未捕获的类型错误:无法读取未定义的属性“模板”
我正在使用剑道网格。
我想在编辑时禁用列。(不是在我添加新记录时)。编辑时写了代码
function onEdit(e) {
var indexCell = 1;
var grid = $('#consumablesGrid').data('kendoGrid');
if (e.model.id) { // when Editing the id is defined
if (indexCell != 'undefined' && grid.columns[indexCell].title == "Consumable") {
grid.closeCell();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它"Uncaught TypeError: Cannot read property 'template' of undefined "在执行时显示grid.closeCell()。
为了更好地理解,我包括我的完整网格条件。
function ConsumableManager() {
$("#consumablesGrid").kendoGrid({
dataSource: {
transport: {
read: {
url: "GetConsumablesGrid",
type: "POST",
contentType: "application/json",
dataType: "json"
},
update: {
url: "UpdateConsumables",
contentType: "application/json",
type: "POST",
dataType: "json", …Run Code Online (Sandbox Code Playgroud) 对于 Kendo UI Grid,可以选择将可过滤设置为行或菜单或两者。我想知道是否可以将某些列设置为行(仅作为行),而其他列显示为菜单(仅作为菜单)。最好不要用css。
示例:我希望字段名称是行过滤器,而年龄是菜单过滤器
<script>
$("#grid").kendoGrid({
dataSource: ...
filterable: {
operators: {
string: {
startswith: "Starts with",
eq: "Exact Client Name",
contains: "contains"
},
number: {
gte: "From",
lte: "Before"
}
},
mode: "row" },
column: [ { field: "ClientName", title: "Client Name", width: 150, type: "string" , attributes: { style: "text-align:left;" }, filterable: { messages: { info: "Show clients that: " }, extra: false} },
{ field: "Month", title: "Month", width: 78, type: "number", attributes: { style: "text-align:center;" …Run Code Online (Sandbox Code Playgroud) 这是一个非编程问题,但我需要对此的建议。(尝试联系 Telerik 但没有回复)
我们计划将 Kendo 与我们的一款单租户 SaaS 产品集成。我们的每个客户都会获得单独的实例。我们已经购买了 Kendo 标准一开发者许可证。我们的客户也必须购买此许可证吗?
谢谢
我正在使用 Kendo Grid,并且我有一个函数,我用它来获取一些 Html 来为我的其中一个列呈现。我的代码如下所示:
{
field: "StateString",
title: "State",
width: "120px",
encoded: true,
template: '#:GetFaClass(data.StateString)#'
}
Run Code Online (Sandbox Code Playgroud)
现在,当我们调用这个函数时,它看起来如下:
function GetFaClass(status) {
if (status == 'Queued') {
return ('<i class="fa fa-folder" aria-hidden="true"></i>')
}
}
Run Code Online (Sandbox Code Playgroud)
有趣的是,它确实调用了该函数并返回值,但随后将其显示为文本而不是呈现 html。现在,如果我不调用该函数,而是像下面那样对值进行硬编码,那么它会呈现良好的效果:
{
field: "StateString",
title: "State",
width: "120px",
encoded: true,
template: ('<i class="fa fa-folder" aria-hidden="true"></i>')
}
Run Code Online (Sandbox Code Playgroud)
我可能做错了什么?
我正在尝试将我的剑道网格导出为 excel。除了格式丢失之外,它工作正常。我认为这是因为我正在使用模板。
Telerik 文档明确指出:
要在将 Grid 导出到 Excel 期间设置单元格值的格式,请设置单元格的格式选项。
我试过这个,但它不起作用:
columns: [
{
field: "EntryWage",
headerTemplate: entryLevelWageColumnHeading + "<span name='EntryWage' class='k-icon k-i-close remove' style='float: right;'></span>",
width: 125,
attributes: { style: "text-align:right;" },
format: "{0:c}",
template: "#= (EntryWage != null) ? kendo.toString(EntryWage, 'C') : 'N/A' #"
}];
Run Code Online (Sandbox Code Playgroud)
我也有这个功能(用于 excel 网格定义):
excelExport: function (e) {
var sheet = e.workbook.sheets[0];
var row = sheet.rows[0];
$("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
row.cells[index].value = $(this).text(); //set cell text …Run Code Online (Sandbox Code Playgroud) 在剑道网格中添加新记录有如下事件:
if (e.model.isNew())
Run Code Online (Sandbox Code Playgroud)
但是为此我必须将它写在“编辑:”中,是否有任何其他功能或方法可以在网格范围之外使用它?
在开始之前,我想说 - 我意识到这个问题与本网站上发布和回答的许多其他问题非常相似。我已经通读并尝试了尽可能多的与我的问题相关的解决方案,但到目前为止没有一个奏效。
我试图将数据从我的网页传递到控制器方法。网页非常简单,只需要抓取用户输入的信息并发送出去即可。我正在使用 Telerik 的 Kendo Grid 来绑定和组织我的数据。但是,无论我尝试什么,我的 AJAX 发布请求都不会正确地向前传递参数。使用浏览器的调试器时,我可以看到传递给 AJAX 请求的参数是有效的,但是当它们在控制器方法中遇到我的断点时,它们都为空或默认值。
包含 AJAX 请求的函数
function saveShiftDataToServer() {
var grid = $("#myGrid").data("kendoGrid");
var dataSource = grid.dataSource;
var allData = dataSource.data();
var comments = '@Model.Comments';
var loadInfoCorrect = '@Model.LoadInfoCorrect';
$.ajax({
type: "POST",
url: '/Home/SaveData',
data: JSON.stringify({ accessorials: allData, comments: comments, loadInfoCorrect: loadInfoCorrect }),
contentType: "application/json; charset=utf-8",
datatype: "json"
})
}
Run Code Online (Sandbox Code Playgroud)
控制器方法
[AcceptVerbs("Post")]
public ActionResult SaveData(Accessorial[] accessorials, string comments, bool loadInfoCorrect)
{
// Code removed for brevity
}
Run Code Online (Sandbox Code Playgroud)
我的 Kendo Grid …
kendo-grid ×10
kendo-ui ×6
jquery ×5
javascript ×4
c# ×2
ajax ×1
asp.net-core ×1
html ×1
html-select ×1
post ×1
telerik ×1