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

Read Only Rows

1 Answer 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
StevenDale
Top achievements
Rank 2
StevenDale asked on 29 Jul 2010, 05:36 PM
Is there a way to make some rows readonly and other editable? Even better would be on the individual cell level.

I have the following scenario. I have a list of items that I need to display both horizontally, which is the normal grid behaviour, and vertically.

To accomplish this I have to build a datatable dynamically based on which option is selected. (horizontal or vertical).

When horizontal is selected I do not have a problem because I can set columns to be readonly. However when I display the data vertically I need the top row, with the exception of the first column which now acts as the headers, to be editable and all other rows to be readonly. I have attached screen shots to demonstrate

Thanks,

Billy Jacobs

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 Jul 2010, 08:32 AM
Hi Billy Jacobs,

A possible approach in your case would be to use the BeginningEdit event of the grid and enable or disable the edit-mode for the columns/ rows you need. For example:

private void playersGrid_BeginningEdit(object sender, Telerik.Windows.Controls.GridViewBeginningEditRoutedEventArgs e)
        {
            GridViewRow row = e.Row as GridViewRow;
 
            if (e.Cell.Column == this.playersGrid.Columns[0] || row.Item as Player == this.playersGrid.Items[0] as Player)
            {
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }          
        }

In this way only the first row and the first column will be editable.

Sincerely yours,
Maya
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
StevenDale
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or