2015-11-26 47 views
0

我在我的应用程序中使用了kendo网格。 在网格中,一行包含一个下拉列表。当我选择下拉列表中的值时,该行中的其他单元格会更新。 但我想使用javascript更新其他单元格。我无法获得此解决方案。如何使用javascript绑定kendo网格单元格

任何人都可以帮助我吗?

我的剑道电网剃刀:

@(Html.Kendo().Grid<models.employee>() 
      .Name("grid") 
      .Columns(columns => 
      { 
       columns.Bound(c => c.name).ClientTemplate(
        "<input type='hidden' name='items[#= index(data)#].name' value='#= getLine(data)#' /> <p>#= getLine(data)#</p>" 
       ); 
       columns.Bound(c => c.Emp_num).EditorTemplateName("EmpEditor").ClientTemplate(
         "#= Emp_num #" + 
         "<input type='hidden' class='Emp-select' name='items[#= index(data)#].Emp_num' id='items[#= index(data)#].Emp_num' value='#= Emp_num #' />" 
        ); 
       columns.Bound(c => c.description).EditorTemplateName("DescripEditor").ClientTemplate(
        "#= description #" + 
        "<input type='hidden' name='items[#= index(data)#].description' data-fill='items[#= index(data)#].description' value='#= description #' />" 
       ); 
columns.Bound(c => c.address).EditorTemplateName("addressEditor").ClientTemplate(
       "#= address #" + 
       "<input type='hidden' name='items[#= index(data)#].address' value='#= address #' data-fill='items[#= index(data)#].address' value='' />" 
      ); 
    }) 

在EmpEditor.cshtml:

@(Html.Kendo().DropDownList() 
    .Name("Emp_num") 
    .OptionLabel("Select Employee Number...") 
    .DataValueField("Emp_num") 
    .DataTextField("Emp_num") 
    .BindTo((System.Collections.IEnumerable)ViewData["Employee"]) 
    .Events(e => e.Select("changes")) 
) 

的javascript:

function changes(e) 
{ 
    var Emp_num = this.dataItem(e.item).Emp_num; // which gives the employee num 

    getEmp(Emp_num, function (emp) { //this function retrieve the details of employee for the particular employee number 

     var Employee = emp; 

     //here I need the code for update the values of Employee.description to description cell and Employee.address to address cell 


    }); 
} 
+0

你应该发布一些代码来帮助人们看到你在做什么。它会提供一些背景,你的问题会得到更多的关注。这也是一个相当广泛的问题,需要知道Kendo UI,JavaScript(jQuery也许......)和HTML。如果你保持合理集中,你通常会发现你会得到更好的答案。 – GP24

回答

0

没有看到你的代码,我想你有某种将你的下拉列表定义为你的kendo-grid列定义的一部分的模板,对吗?您需要编写一个JavaScript函数来更新单元格并将其添加到此下拉列表的onChange。剑道文件可能涵盖了这一点。

相关问题