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

[Solved] Questions about IsReadOnly and CellEditTemplate

1 Answer 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kazimierz Szadkowski
Top achievements
Rank 1
Kazimierz Szadkowski asked on 17 Feb 2010, 07:51 AM
I have two unrelated questions about RadGridView control.
1. I have a grid with 'IsReadOnly', 'CanUserInsertRows' and 'ShowInsertRow' properties set to 'true'. This way user can add new record after clicking on "Click here to add new item" row. He can also edit every cell of every row simply by double-clicking on it. What I need is to block editing while allowing to insert. Editing should be only possible after selecting "Edit" from context menu, but not after double-click. My first idea was to set grid's 'IsReadOnly' property to false, which blocks  double-click editing and set it to true when user selects "Edit" in menu. Problem is, setting 'IsReadOnly' to false disables the "Click here to add..." row, and I want user to be able to add new items with it. Is there a solution?

2. Second question regads "CellEditTemplate". I have a column:
<grid:GridViewDataColumn Header="Role" UniqueName="Role" DataMemberBinding="{Binding Role.Name}"
    <grid:GridViewDataColumn.CellEditTemplate> 
        <DataTemplate> 
            <input:RadComboBox x:Name="rcbRole" Loaded="rcbRole_Loaded" /> 
        </DataTemplate> 
    </grid:GridViewDataColumn.CellEditTemplate> 
</grid:GridViewDataColumn> 
When row is edited combobox appears from which user selects role. Questions is, when user ends editing how can I get the value he selected from combobox? There is an event, RowEditEnded, where I take new record and send it via WCF to server side, like this:
private void RadGridView1_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) 
    if ( e.EditAction == GridViewEditAction.Cancel ) 
    return; 
 
    User user = (User)e.NewData; 
     
    if (e.EditOperationType == GridViewEditOperationType.Edit) 
        proxy.UpdateUserAsync(user); 
    else 
        proxy.InsertUserAsync(user); 
New 'User' object is however incomplete, as I don't know what role user selected. I cannot use binding in the same way as with other properties of User, because role is not just a string or int.
I woud be most grateful for any tips. Thanks.

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 18 Feb 2010, 11:43 AM
Hello Kazimierz Szadkowski,

Straight onto your questions:

#1. Indeed RadGridView doesn't have property such as "CanUserEditRows". We will consider adding similar property for the next official release. Meanwhile you can set all columns "IsReadOnly" property to true in order to stop editing and reverse it when user add new row. I'm attaching a sample application for a reference.

#2. I think that you can use the default GridViewComboBoxColumn in your scenario. Please take a look at the "Position" column from the attached example.

Kind regards,
Nedyalko Nikolov
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
GridView
Asked by
Kazimierz Szadkowski
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or