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

[Solved] Change ReadOnly property in OnEdit event

2 Answers 141 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.
Donna Stewart
Top achievements
Rank 1
Donna Stewart asked on 01 Sep 2011, 04:49 PM
I have a grid with a couple of columns I want to be ReadOnly during Edit mode,but I want them to be editable in Insert mode.  I know I can check the mode during the OnEdit event and I hope I can change the ReadOnly property if the mode is 'insert'.  These columns are using EditorTemplates for dropdown lists.  Is this possible?  If so, how do I change that ReadOnly property?  I am using batch editing and I want those columns to be visible, just not changeable unless they are inserting a new row.  Your help is very much appreciated! 
Thank you!
Donna

Here is the grid code:
<%= Html.Telerik().Grid(Of GMC_Hub_and_Spoke.OnlineReportDetailModel).Name("InputPropertiesGrid").HtmlAttributes(New With {.style = "width:95%;"}) _
    .DataKeys(Function(key) key.Add(Function(k) k.WQIKey)) _
    .ToolBar(Function(commands) commands.SubmitChanges()) _
    .ToolBar(Function(commands) commands.Insert()) _
    .ClientEvents(Function(events) events.OnError("onGridError")) _
    .ClientEvents(Function(events) events.OnEdit("onGridEdit")) _
    .DataBinding(Function(dataBinding) dataBinding.Ajax().Select("GetInputProperties", "WebQuery", New With {.id = Model.selectedWebQuery.QueryKey}).Update("SaveInputProperties", "WebQuery")) _
    .Editable(Function(editing) editing.Mode(GridEditMode.InCell)) _
    .Columns(Function(col) col.Bound(Function(p) p.Caption)) _
    .Columns(Function(col) col.Bound(Function(p) p.ReportDataType).ReadOnly(True)) _
    .Columns(Function(col) col.Bound(Function(p) p.DisplayType).ReadOnly(True)) _
    .Columns(Function(col) col.Bound(Function(p) p.InputValue)) _
    .Columns(Function(col) col.Bound(Function(p) p.DisplayOrder)) _
    .Columns(Function(col) col.Bound(Function(p) p.Visible)) _
    .Columns(Function(col) col.Bound(Function(p) p.MinLength)) _
    .Columns(Function(col) col.Bound(Function(p) p.MaxLength)) _
    .Columns(Function(col) col.Bound(Function(p) p.MinDate)) _
    .Columns(Function(col) col.Bound(Function(p) p.MaxDate)) _
    .Columns(Function(col) col.Bound(Function(p) p.StoredProcParameter).ReadOnly(True)) _
    .Columns(Function(col) col.Bound(Function(p) p.WQIKey).Hidden(True))
    %>


2 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 02 Sep 2011, 03:30 PM
Hello Donna, 

I'm afraid that this is not possible. Once you set the ReadOnly property, it cannot be changed at runtime.



Regards,
Georgi Tunev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Donna Stewart
Top achievements
Rank 1
answered on 02 Sep 2011, 04:49 PM
Is there maybe another way I can do this?  Any suggestions?

EDIT:  Nevermind - I found a  workaround in this forum post.  Not sure why I didn't see that post in all of my forum searches yesterday.  I just happened to stumble upon it today.  I thought I would add this and the link in case anyone else has this need.
Thanks,
Donna
Tags
Grid
Asked by
Donna Stewart
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Donna Stewart
Top achievements
Rank 1
Share this question
or