最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - kendo grid select cell data on focus - Stack Overflow

programmeradmin2浏览0评论

Is there a way to highlight (select all the text) in a cell inside a Kendo Grid when focus is on the cell? When I tab or click into the columns I would like the text in that cell to auto highlight. Thank you in advance for any assistance.

I have the below code:

@(Html.Kendo().Grid<ExerciseBreakdownViewModel>()
          .Name(string.Format("Grid"))
          .Columns(columns =>
          {
              columns.Bound(p => p.Id).Visible(false);
              columns.Bound(p => p.PersonnelName).Width(120);
              columns.Bound(p => p.NumberOfTeams).Width(120);
              columns.Bound(p => p.TeamMembers).Width(110);
              columns.Bound(p => p.Vehicles).Width(80);
              columns.Bound(p => p.Brief).Format("{0:HH:mm}").EditorTemplateName("BriefTimePicker").Width(80);
              columns.Bound(p => p.KickOff).Format("{0:HH:mm}").EditorTemplateName("KickoffTimePicker").Width(80);
              columns.Bound(p => p.Debrief).Format("{0:HH:mm}").EditorTemplateName("DebriefTimePicker").Width(80);
          })
          .Editable(editable => editable.Mode(GridEditMode.InCell))
          .HtmlAttributes(new { style = "height:400px;" })
          .Navigatable()
          .Scrollable()
          .DataSource(dataSource => dataSource
              .Ajax()
              .PageSize(20)
              .Events(events => events.Error("error_handler"))
              .Model(model =>
              {
                  model.Id(p => p.Id);
                  model.Field(p => p.PersonnelName).Editable(false);
                  model.Field(p => p.NumberOfTeams);
                  model.Field(p => p.TeamMembers);
                  model.Field(p => p.Vehicles);
                  model.Field(p => p.Brief);
                  model.Field(p => p.KickOff);
                  model.Field(p => p.Debrief);
              })
             .Read("Personnel_Read", "Schedule", Model)
          )
    )

Is there a way to highlight (select all the text) in a cell inside a Kendo Grid when focus is on the cell? When I tab or click into the columns I would like the text in that cell to auto highlight. Thank you in advance for any assistance.

I have the below code:

@(Html.Kendo().Grid<ExerciseBreakdownViewModel>()
          .Name(string.Format("Grid"))
          .Columns(columns =>
          {
              columns.Bound(p => p.Id).Visible(false);
              columns.Bound(p => p.PersonnelName).Width(120);
              columns.Bound(p => p.NumberOfTeams).Width(120);
              columns.Bound(p => p.TeamMembers).Width(110);
              columns.Bound(p => p.Vehicles).Width(80);
              columns.Bound(p => p.Brief).Format("{0:HH:mm}").EditorTemplateName("BriefTimePicker").Width(80);
              columns.Bound(p => p.KickOff).Format("{0:HH:mm}").EditorTemplateName("KickoffTimePicker").Width(80);
              columns.Bound(p => p.Debrief).Format("{0:HH:mm}").EditorTemplateName("DebriefTimePicker").Width(80);
          })
          .Editable(editable => editable.Mode(GridEditMode.InCell))
          .HtmlAttributes(new { style = "height:400px;" })
          .Navigatable()
          .Scrollable()
          .DataSource(dataSource => dataSource
              .Ajax()
              .PageSize(20)
              .Events(events => events.Error("error_handler"))
              .Model(model =>
              {
                  model.Id(p => p.Id);
                  model.Field(p => p.PersonnelName).Editable(false);
                  model.Field(p => p.NumberOfTeams);
                  model.Field(p => p.TeamMembers);
                  model.Field(p => p.Vehicles);
                  model.Field(p => p.Brief);
                  model.Field(p => p.KickOff);
                  model.Field(p => p.Debrief);
              })
             .Read("Personnel_Read", "Schedule", Model)
          )
    )
Share Improve this question asked Mar 25, 2014 at 16:04 Corey WitherowCorey Witherow 2,4723 gold badges28 silver badges37 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Add an Edit event to your grid. .Events(x => x.Edit("edit"))

function edit(e) {

    var input = e.container.find("input");      
        input.select();       
}
发布评论

评论列表(0)

  1. 暂无评论