2

次のような剣道グリッドがあります。

 @(Html.Kendo().Grid<UserHolidayRightDto>()
.Name("gridHoliday")
.ToolBar(tool=>tool.Create())
.Columns(columns =>
{
columns.Bound(p => p.Date).Format("{0:MM/dd/yyyy}").Title("Date added");
columns.Bound(p => p.ValidForYear).Title("For year");
columns.ForeignKey(p => p.RightTypeId,  
System.Collections.IEnumerable)     
 @Model.HolidayRightsView, "Id", "Name").Title("Right type").HtmlAttributes(new   
{@Id="HolidayRightsDropDown"});
columns.Bound(p => p.Days).Title("Days");
columns.Bound(p => p.Comment).Title("Comment");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
}) 
.Scrollable(s=>s.Height(200)) 
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Events(e=>e.Edit("edit"))
.Events(e=>e.DataBound("onDataBound"))
.DataSource(dataSource => dataSource
.Ajax() 
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.ValidForYear).Editable(false).DefaultValue(@DateTime.Now.Year);
model.Field(p => p.Date).Editable(false); 
}) 
.Events(e=>e.RequestEnd("UpdateWindow")) 
.Read(read=>read.Action("ReadData","HolidayRights",new {id=@Model.Employee.PersonID}))
.Create(update => update.Action("EditingInline_Create", "HolidayRights",new    
{personId=@Model.Employee.PersonID})) 
.Update(update => update.Action("EditingInline_Update", "HolidayRights"))
.Destroy(update => update.Action("EditingInline_Destroy", "HolidayRights"))
 ))

外部キー列を作成モードで編集可能にし、編集モードで無効にしたいと考えています。私は次のような解決策を試しました: $("#HolidayRightsDropDown").attr("readonly", true);

または var d = document.getElementById("HolidayRightsDropDown"); d.disabled = true;

または closecell() - ただし、この関数はセル編集に対してのみ機能しますが、成功しません。

助言がありますか?

4

1 に答える 1

0

Id 属性は、ドロップダウンの実際の入力ではなく、列要素 (td) にのみ適用されます。グリッド編集機能については、以下のコードを試してください

function gridEdit(e) {
    if (!e.model.isNew()) {
        var input = $("input[name='RightTypeId_input']");
        input.prop('disabled', true);
        input.addClass("readonly"); // add custom css class to make it looks 'disabled' 
        // avoid clicking on Kendo spans
        input.next('span.k-select').unbind("click");
    }
}

CSS

input.readonly
{
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
-o-user-select:none;
background-color:#E6E6E6 !important;
}
于 2014-02-18T06:43:46.543 に答える