Kendo ui 如何确定哪个行或控件正在进行DropDownList读取数据调用

Kendo ui 如何确定哪个行或控件正在进行DropDownList读取数据调用,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我在剑道网格中有一个DropDownListFor控件,我需要该行中另一个元素的值,以便将参数传递给DropDownList的服务器端读取方法。它的设置与示例类似 以下是定义DropDownList for的代码: @(Html.Kendo().DropDownListFor(m => m) .Name("LinkIdentifier") .OptionLabel("---Select Form, etc.---") .DataValueField("ID") .DataTextField

我在剑道网格中有一个DropDownListFor控件,我需要该行中另一个元素的值,以便将参数传递给DropDownList的服务器端读取方法。它的设置与示例类似

以下是定义DropDownList for的代码:

@(Html.Kendo().DropDownListFor(m => m)
.Name("LinkIdentifier")
.OptionLabel("---Select Form, etc.---")
.DataValueField("ID")
.DataTextField("Name")
.AutoBind(false)
.DataSource(source =>
{
     source.Read(read =>
     {
         read.Action("LinkTypeIdentifierDdl", "Alerts").Type(HttpVerbs.Post).Data("getCurrentLinkType");
     }).ServerFiltering(true);
})
)
下面是在.Data中调用的javascript函数:

function getCurrentLinkType() {
    var grid = $("#linkGrid").data("kendoGrid");
    var data = grid.dataSource.data();
    var dataItem = data[0];
    var valueForParameter = dataItem.SomeValue
    //--snipped for brevity
}
上面的问题是数据[0]。它只指向网格中的第一行,如果编辑任何其他行,这将是不正确的。如果我在这个方法中使用javascript调试器并查看“this”,那么引用的是AJAX调用,而不是下拉控件。我无法指定“.Data”(“getCurrentLinkType(this)”)作为方法


那么,我如何确定哪一行/控件调用了getCurrentLinkType?

没有从网格到DropDownList再到数据函数的上下文,所以您需要自己解决这个问题

我找到了两种方法

1:

2:


如果将
console.log(arguments)
添加到
getCurrentLinkType()
?@DontVoteMeDown的第一行,您会得到什么?我测试了这一点,传递给函数的唯一参数是一个包含datasource筛选器对象的对象,该对象为空,即筛选器{filters:[],逻辑:“and”}
// If your grid is single Selectable(), use the current selection
var dataItem = grid.dataItem(grid.select());
// If your grid is not Selectable or is multi Selectable, get the row/tr closest to the editor and then get the dataItem from that
var dataItem = grid.dataItem($("#LinkIdentifier").closest("tr"));