2011-09-20 3 views
1

"작성일"열이있는 telerik 그리드가 있습니다. 이 날짜를 볼 수는 있지만 편집 할 수 없도록하려면 ReadOnly로 설정합니다. 그러나 읽기 전용이므로 속성은 내 컨트롤러에 바인딩되지 않습니다. CreateDate는 null이됩니다. 읽기 전용으로 만들려면 어떻게해야합니까?Telerik Grid 용 읽기 전용 열을 바인딩하는 방법

@(Html.Telerik().Grid(Model) 
.Name("MainGrid") 
.ToolBar(commands => commands.Insert()) 
    .DataKeys(keys => keys.Add(c => c.ID).RouteKey("ID")) 
.DataBinding(databinding => databinding 
    .Server() 
     .Insert("Insert", "Main") 
     .Update("Update", "Main") 
     .Delete("Delete", "Main")) 
.Columns(columns => 
{ 
    columns.Bound(o => o.Name).Width(200); 
    columns.Bound(o => o.CreatedDate).Format("{0:MMM dd, yyyy HH:mm}").ReadOnly().Width(150); 
columns.Command(commands => 
     { 
      commands.Edit(); 
      commands.Delete(); 
     }); 

답변

1

참조 .Editable (구성자) 즉. 이 등 대신 .Columns (호출로 끝나는의 .Columns()와 같은 수준에 사용되는 격자 방법)이다, 이런 식으로 뭔가를 추가하는 것을 시도 :

... 
    .Editable(editing => 
    { 
     var newItem = new SomeEntity 
     { 
      Name = "defaultName", 
      CreateDate = DateTime.Now, 
      OtherProperty = otherValue() 
     }; 
     editing.DefaultDataItem(newItem); 
    }); 
0

검도 MVC의 V 2014.1를.

그런 다음
.DataSource(dataSource => dataSource 
    .Ajax() 
    .PageSize(20) 
    .Model(model => 
    { 
     model.Id(p => p.Id); 
     model.Field(f => f.CreatedDate).Editable(false); 
     model.Field(f => f.WhateverColumnYouHaveDefined).Editable(false); 
    } 
) 

가 결합되며, 디스플레이,하지만 편집 할 수 없습니다 : 당신은 그리드에 원하는 칼럼 (528)

넣고 .. 그리고

.Datasource에서, 편집 할 수 있습니다 열을 말한다 .

희망이 있습니다.

관련 문제