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

Cell IsReadOnly not applied till after the cell is edited

4 Answers 18 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 25 Oct 2012, 03:23 AM
I am using the Gridview Product Version 2012.1.0430.1050

I am binding the grid to an observable collection.
<telerik:RadGridView x:Name="ACGrid" IsFilteringAllowed="False" Style="{StaticResource TelerikGridStyle}" ItemsSource="{Binding LPItemEditList, Mode=TwoWay}"
                                SelectedItem="{Binding SelectedLPItemEdit, Mode=TwoWay}">

I am using the Event trigger
On some of the columns are editable based on a bool (HasOnshore) on the VM bound to IsReadOnly
<telerik:GridViewDataColumn Header="Onshore Ask" DataMemberBinding="{Binding OnshoreAsk,StringFormat=F1}" TextAlignment="Right" Width="65"
        HeaderTextAlignment="Right" IsReadOnly="{Binding HasOnshore}" Background="{Binding LPSetVM.BkOnshore, Source={StaticResource Locator}}"
        CellStyleSelector="{StaticResource lPEditedSelector}" />

After the Grid is loaded I can still enter edit mode for the columns that are using the binding. After leaving the column (either tab or mouse) the isReadOnly binding takes effect and the column is no longer editable. Columns that have not been edited can still be edited.

If I use ENTER or click into another cell in the same column the IsReadOnly does NOT get implemented and I can continue to edit the record.

Steps takes:
Displayed the bool to insure the change of the values in the VM
I changed to IsReadOnlyBinding - this did not work at all and the cells remained editable for both True and False values

4 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 25 Oct 2012, 01:22 PM
Hello Mark,

Indeed, this is expected behaviour when you try to bind the IsReadOnly property. I suggest you to use the IsReadOnlyBinding property. More about it you can find here. For your convenience I have attached sample project showing you the approach.

Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mark
Top achievements
Rank 1
answered on 29 Oct 2012, 05:31 AM
Aha I think I see my error, I want to make the ENTIRE column readonly based on 1 property in the VM not each cell individually. 

Individual cell control is not the way I interpreted IsReadOnlyBinding but your example will be very useful if I need this option.

So how can I lock down a column based on a single property? I'm currently using the following but it is not applied till after editing the column.

<telerik:GridViewDataColumn Header="TLM Bid" DataMemberBinding="{Binding TLMBid,StringFormat=F1}" TextAlignment="Right" Width="65" HeaderTextAlignment="Right"
        IsReadOnly="{Binding HasTLM}" Background="{Binding LPSetVM.BkTLM, Source={StaticResource Locator}}" CellStyleSelector="{StaticResource lPEditedSelector}" />

0
Accepted
Yoan
Telerik team
answered on 31 Oct 2012, 04:20 PM
Hello Mark,

In order to achieve this, you can set the boolean properties of your business object to True. Please check my modified project to see what I mean.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mark
Top achievements
Rank 1
answered on 01 Nov 2012, 01:02 AM
Thanks Yoan, that makes perfect sense, nesting the binding to point to the datacontext of the Grid
IsReadOnlyBinding="{Binding IsReadonly}

Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Mark
Top achievements
Rank 1
Share this question
or