选定行的Kendo Grid内联编辑无法正常工作

时间:2016-05-16 06:13:11

标签: kendo-ui telerik kendo-grid telerik-grid

我的剑道网格都选择了行和内联编辑功能。当我单击编辑按钮而不选择行时,它会显示我正在进行的更改。 enter image description here

但如果我先选择一行然后尝试编辑它会隐藏所有值。  enter image description here

我的网格代码

@(Html.Kendo().Grid<VmSegment>()
      .Name("VmSegment")
      .Events(e => e.Change("onChange"))
      .Columns(columns =>
      {
          columns.Group(group => group
              .HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"})
              .Title("Chainage (m)")
              .Columns(info =>
              {
                  info.Bound(p => p.FromChain).HtmlAttributes(new {style = "text-align:right"}).Title("From").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(40);
                  info.Bound(p => p.ToChain).HtmlAttributes(new {style = "text-align:right"}).Title("To").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(40);
              })
              );
          columns.Template(p => { }).Title("Segment Length").HtmlAttributes(new {style = "text-align:right"}).HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).ClientTemplate("#=calculate(data)#").Width(60);

          columns.Bound(p => p.SurfaceType).ClientTemplate("#=SurfaceType.surfaceTypeName#").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Title("Surface Type").Width(55);

          columns.Group(group => group
              .HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"})
              .Title("Average Width (m)")
              .Columns(info =>
              {
                  info.Bound(p => p.AvgCargW).HtmlAttributes(new {style = "text-align:right"}).Title("Carriage").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(70);
                  info.Bound(p => p.AvgShoulW_R).HtmlAttributes(new {style = "text-align:right"}).Title("Shoulder Right").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(70);
                  info.Bound(p => p.AvgShoulW_L).HtmlAttributes(new {style = "text-align:right"}).Title("Shoulder Left").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(70);
              })
              );
          columns.Group(group => group
              .HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"})
              .Title("Condition")
              .Columns(info =>
              {
                  info.Bound(p => p.SlopeCondition).ClientTemplate("#=SlopeCondition.Name#").Title("Slope").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(60);
                  info.Bound(p => p.ShoulderCondition).ClientTemplate("#=ShoulderCondition.Name#").Title("Shoulder").HeaderHtmlAttributes(new {style = "text-align:center;font-weight:bold;vertical-align: middle"}).Width(60);
              })
              );
          columns.Command(command =>
          {
              command.Edit().HtmlAttributes(new {style = "text-align:center", @id = "Edit", title = "Edit"}).Text(" ");
              command.Destroy().HtmlAttributes(new {@id = "rm", title = "Delete"}).Text(" ");
              command.Custom("ViewMap").Click("showMap").HtmlAttributes(new {@class = "", @id = "", title = "Map"}).Text(" ");
              command.Custom("ViewDetails").Click("showDetails").HtmlAttributes(new {@class = "", @id = "target3", title = "Details"}).Text(" ");
              command.Custom("ViewPhoto").Click("showPhoto").HtmlAttributes(new {@class = "", @id = "", title = "Photo"}).Text(" ");
          }).Width(120);
      })
      .ToolBar(toolBar => toolBar.Template("<a style = 'text-align:center;font-weight:bold;hover' title='First select a row.' class='k-button k-button-icontext add'></span>+Add New Record</a>")) // The "create" command adds new data items
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Selectable(selectable => selectable
                .Type(GridSelectionType.Row))  
      //.Sortable()
      .Pageable(pageable => pageable.Refresh(true))
      .ColumnMenu()
      .DataSource(dataSource => dataSource          
          .Ajax()
          .PageSize(10)

          .Events(e =>
          {
              //e.Error("onError");
              e.Sync("KendoGridRefresh");
              // e.Change("onChange");
              //e.Change("onChange");
          })
          .Model(model =>
          {
              model.Id(p => p.Id);

              model.Field(p => p.FromChain).Editable(false);

              model.Field(p => p.SurfaceType).DefaultValue(
                  ViewData["defaultSurfaceType"] as VmSurfaceType);

              model.Field(p => p.SlopeCondition).DefaultValue(
                  ViewData["defaultconditionSlope"] as VmCondition);

              model.Field(p => p.ShoulderCondition).DefaultValue(
                  ViewData["defaultconditionShoulder"] as VmConditionShoulder);
          })
          .Read(r => r.Action("Read", "Segment"))
          .Create(r => r.Action("Create", "Segment"))
          .Update(r => r.Action("Update", "Segment"))
          .Destroy(r => r.Action("Delete", "Segment"))
      )
      .Events(ev => ev.DataBound("resetRowNumber").DataBound("onRowBound"))
      .Events(ev => ev.Cancel("onCancel"))


      )

1 个答案:

答案 0 :(得分:0)

实际上问题是当我选择任何行并进入编辑选项时,该行的背景颜色变为白色。结果,它不显示数据。只需更改.k状态选定的类​​背景颜色。