2017-09-15 70 views
0

我的RadDataGrid控件包含DataGridBooleanColumn列,它應該是可編輯的,其他列不可編輯,我在DataGridBooleanColumn列中設置了屬性CanUserEdit =「True」,但該列中的複選框仍然不可編輯。如何只編輯一列RadDataGrid?RadDataGrid用戶只能編輯一列

+0

可編輯的列是這樣的 - 「 「 – xyzWty

+0

你有編輯命令列嗎?你的代碼與這個演示有什麼不同? http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/automatic-crud-operations/defaultcs.aspx – Seano666

+0

@ Seano666這個控件是在ASP.net中,我的控件是在Windows UWP中。 – xyzWty

回答

0

我們應該能夠將RadDataGridUserEditMode屬性設置爲Inline。默認值UserEditModeNone,表示不允許編輯。

如果您只想編輯RadDataGrid的一列,您應該可以將其他列的CanUserEdit設置爲False。默認值CanUserEditTrue

例如:

<telerikGrid:RadDataGrid ItemsSource="{Binding}" AutoGenerateColumns="False" UserEditMode="Inline"> 
    <telerikGrid:RadDataGrid.Columns > 
     <telerikGrid:DataGridTextColumn PropertyName="Product" Header="Product" CanUserEdit="False"/> 
     <telerikGrid:DataGridBooleanColumn PropertyName="Stock" Header="Stock" CanUserEdit="True" /> 
    </telerikGrid:RadDataGrid.Columns> 
</telerikGrid:RadDataGrid> 

代碼後面:

public sealed partial class MainPage : Page 
{ 

    ObservableCollection<Data> Products; 

    public MainPage() 
    { 
     this.InitializeComponent(); 
     Products = new ObservableCollection<Data>() 
     { 
     new Data { Product = "Milk", Stock = true }, 
     new Data { Product = "Cheese", Stock = false }, 
     new Data { Product = "Bread", Stock = false }, 
     new Data { Product = "Chocolate", Stock = true } 
     }; 
     this.DataContext = Products; 
    } 
} 
public class Data 
{ 
    public string Product { get; set; } 
    public bool Stock { get; set; } 
} 
+0

感謝您的幫助,因爲我不想使用這種替代方案,我之前也嘗試過這種解決方案,但用戶必須雙擊該行然後只有用戶能夠更改選擇,我希望用戶選擇一次只在布爾列上編輯該值。請幫助。 – xyzWty

相關問題