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

[Solved] Setting a Column to be Editable only for Insert

1 Answer 69 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.
Derrick
Top achievements
Rank 1
Derrick asked on 02 Dec 2011, 04:46 AM
I have a requirement to set a column (call it TitleValue) to be readonly in editing mode, but NOT in Insert. The idea is to be able to add new values in an insert, but once the value is in the grid, not being able to edit it. For this example, I have setup a EditorTemplate for this column to be a DropDown. So far, I am only able to make BOTH edit and insert either readonly or not. I want the Insert mode to be editable, but not the Edit mode (Edit should be readonly).

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 05 Dec 2011, 09:35 AM
Hello Derrick,

Basically to disable the DropDown menu in edit mode only, you need to hook up a JavaScript function to the OnEdit client event. The function itself should check if the mode is "edit" and disable the DropDown list.

e.g.

//...
.ClientEvents(events=> events.OnEdit("DisableDropdown"))

JavaScript:
function DisableDropdown(e) {
        if (e.mode == "edit") {
            $('#DropDownID').attr('disabled', 'disabled');
        }
}

I hope this answers your question. 


Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Derrick
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or