gpt4 book ai didi

javascript - Kendo grid 错误 : kendo. all.min.js :12 Uncaught TypeError: e. slice is not a function

转载 作者:行者123 更新时间:2023-11-30 16:32:29 25 4
gpt4 key购买 nike

我有一个剑道网格,它使用来自 javascript 的 ajax 绑定(bind)其数据源,如下所示:

剑网:

@(Html.Kendo().Grid<WEB02.ConfigurationModel.ActivityGridDetails>()
.Name("Activitydet")
.Columns(columns =>
{
columns.Bound(o => o.Id).Width(40);
columns.Bound(o => o.Config).Width(200);
columns.Bound(o => o.Status).Width(250);
columns.Bound(o => o.In).Width(250);
columns.Bound(o => o.Out).Width(250);




})
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
)
)
)

Javascript:

function onChange(e) {
var grid = $("#grid").data("kendoGrid");
var dataRows = grid.items();
var rowIndex = dataRows.index(grid.select());
var selectedname = grid.dataItems()[rowIndex];
console.log("aly" + selectedname.NodeId);
document.getElementById("ActivityGrid").style.bottom = "100px";



$.ajax({

type: 'POST',
url: '/Configuration/ActivityGridDisplay/',
dataType: 'json',
data: { nodeName: selectedname.Name, nodeType: selectedname.Type, nodeID: selectedname.NodeId },
success: function (result) {

$("#Activitydet").data("kendoGrid").dataSource.data(result);
//$("#Activitydet").data("kendoGrid").dataSource.fetch();
}
})}

Controller :

public ActionResult ActivityGridDisplay([DataSourceRequest] DataSourceRequest request, string nodeName, string nodeType, string nodeID)

{



ActivityGrid Activity = new ActivityGrid();
Activity.Grid = new DataTable();

string rep = "ns=2;s=";
nodeID = nodeID.Replace(rep, "");

string nodeConfig= nodeID+".CONFIG";
string nodeStatus= nodeID+".STATUS";
string nodeIN= nodeID+".IN";
string nodeOUT= nodeID+".OUT";
Dictionary<string, string> ActivityConfig = RxMUaClient.DetailsBrowse("2", "127.0.0.1:48030", nodeConfig);
Dictionary<string, string> ActivityStatus = RxMUaClient.DetailsBrowse("2", "127.0.0.1:48030", nodeStatus);
Dictionary<string, string> ActivityIN = RxMUaClient.DetailsBrowse("2", "127.0.0.1:48030", nodeIN);
Dictionary<string, string> ActivityOUT = RxMUaClient.DetailsBrowse("2", "127.0.0.1:48030", nodeOUT);


List<Dictionary<string, string>> Collection = new List<Dictionary<string, string>>();
Collection.Add(ActivityConfig);
Collection.Add(ActivityStatus);
Collection.Add(ActivityIN);
Collection.Add(ActivityOUT);

int max =Collection[0].Count;
for (int CC = 1; CC < 4; CC++)
{

if (Collection[CC].Count > max)
{
max = Collection[CC].Count;
}
}
DataTable Table = new DataTable();
Table.Columns.Add("Id");
Table.Columns.Add("Config");
Table.Columns.Add("Status");
Table.Columns.Add("In");
Table.Columns.Add("Out");
for (int i = 0; i <= max; i++)
{
DataRow newRow = Table.NewRow();
newRow[0] = i;

int l=1;
foreach (Dictionary<string, string> e in Collection)
{

if (i < e.Count)
{
var element = e.ElementAt(i);
newRow[l] = element.Value;
}
l++;

}
Table.Rows.Add(newRow);

}



if (request.Aggregates.Any())
{
request.Aggregates.Each(agg => agg.Aggregates.Each(a =>
{
a.MemberType = Table.Columns[agg.Member].DataType;
}));
}
return Json(Table.ToDataSourceResult(request));

我之前使用模型完成了相同的网格,但直接从剑道网格中使用读取函数,它过去没有问题。这次使用 ajax 绑定(bind)读取不起作用,因为它给出了这个错误:kendo.all.min.js:12 未捕获类型错误:e.slice 不是函数

我尝试将 allowget 放入 json 调用但没有解决它,我之前没有设置模型 ID 所以我设置了一个但也没有解决它。我试图从剑道网格中删除数据源部分,但没有成功。有什么建议么??

最佳答案

发现问题:它在 javascript 部分,因为整个数据都被传递了,而应该只传递数据数组部分:

ajax函数修改如下:

 $.ajax({

type: 'POST',
url: '/Configuration/ActivityGridDisplay/',
dataType: 'json',
data: { nodeName: selectedname.Name, nodeType: selectedname.Type, nodeID: selectedname.NodeId },
success: function (result) {
console.log(result);
var pass = result.Data;
$("#Activitydet").data("kendoGrid").dataSource.data(pass);
//$("#Activitydet").data("kendoGrid").dataSource.fetch();
}
})

关于javascript - Kendo grid 错误 : kendo. all.min.js :12 Uncaught TypeError: e. slice is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33128456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com