This is a migrated thread and some comments may be shown as answers.

[Solved] How to avoid editing pk?

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Will Yeung
Top achievements
Rank 1
Will Yeung asked on 04 Mar 2010, 07:19 AM
Hello~
for editing ajax. COLUMN_NAME and SPEC_TABLE_NAME are my pk.
when the edit was clicked, they became text boxes also. How to not make them textbox?
Thanks~

<%= Html.Telerik().Grid(Model)
                .Name("Grid")
        .DataKeys(keys => 
        {
            keys.Add(c => c.COLUMN_NAME);
            keys.Add(c => c.SPEC_TABLE_NAME);
        })
        .Toolbar(commands => commands.Insert())
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_SelectAjaxEditing", "INFO_COLUMN")
                .Insert("_InsertAjaxEditing", "INFO_COLUMN")
                .Update("_SaveAjaxEditing", "INFO_COLUMN")
                .Delete("_DeleteAjaxEditing", "INFO_COLUMN");
        })
        .Columns(columns =>
        {
            columns.Bound(c => c.COLUMN_NAME);
            columns.Bound(c => c.SPEC_TABLE_NAME);
            columns.Bound(c => c.CODE_TABLE_QUERY);
            columns.Bound(c => c.CODE_TABLE_NAME);
            //columns.Bound(c => c.BirthDay).Width(130).Format("{0:d}");
            columns.Command(commands =>
            {
                commands.Edit();
                commands.Delete();
            }).Width(180);
        })
        .Sortable()
        .Filterable()

%>

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 04 Mar 2010, 09:04 AM
Hi Will Yeung,

You should decorate those properties with the ReadOnly attribute:

[ReadOnly(true)]
public string CustomerID
{
    get;
    set;
}

Currently there is a problem with the Ajax editing - in edit mode readonly columns will get empty. We will fix that for the official release.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Will Yeung
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or