7 Answers, 1 is accepted
May you please elaborate your problem in more details? Are you using the built-in GridViewCheckBox column or you have defined the CellTemplate for a particular GridViewDataColumn?
I believe that the following online help article would be helpful on that matter, please follow this link.
Vanya Pavlova
the Telerik team
Please find the below code how i am using RadTreeListView
<RadTreeListView x:Name="FrameworkPermissions"
ItemsSource="{Binding Path=RolePermissionsList, Mode=TwoWay}"
IsReadOnly="False"
AutoGenerateColumns="False"
Loaded="FrameworkPermissions_Loaded"
CanUserFreezeColumns="False" IsFilteringAllowed="False" GridLinesVisibility="Both"
ShowGroupPanel="False"
AllowDrop="False" RowLoaded="FrameworkPermissions_RowLoaded">
<RadgTreeListView.ChildTableDefinitions>
<RadTreeListViewTableDefinition ItemsSource="{Binding Children}" />
</RadTreeListView.ChildTableDefinitions>
</RadTreeListView>
In the FrameworkPermissions_RowLoaded method i am adding datacoloums as follows
GridViewDataColumn tempDataColumn = new GridViewDataColumn();
tempDataColumn = new GridViewDataColumn()
{
UniqueName = "Task",
DataMemberBinding = new Binding("TaskName") { Mode = BindingMode.TwoWay }
,
Width = 200
};
Plz Help
Thank you for sharing this snippet to us!
Generally it is not a good idea to define columns in RowLoaded event since it is being fired each time the row appears in the view port. More appropriate would be to subscribe to the RadTreeListView's DataLoaded event and create the column there and specify the CellTemplate as it was described in the previously referenced help article.
Please refer to the snippets below:
MainWindow.xaml
<
Grid
x:Name
=
"LayoutRoot"
DataContext
=
"{Binding Source={StaticResource SampleDataSource}}"
>
<
Grid.Resources
>
<
DataTemplate
x:Key
=
"dt"
>
<
CheckBox
IsChecked
=
"{Binding TaskName, Mode=TwoWay}"
telerik:StyleManager.Theme
=
"Office_Black"
/>
</
DataTemplate
>
</
Grid.Resources
>
<
telerik:RadTreeListView
ItemsSource
=
"{Binding Collection}"
DataLoaded
=
"FrameworkPermissions_DataLoaded"
x:Name
=
"FrameworkPermissions"
Margin
=
"88,40,232,154"
RowLoaded
=
"FrameworkPermissions_RowLoaded"
>
<
telerik:RadTreeListView.ChildTableDefinitions
>
<
telerik:TreeListViewTableDefinition
ItemsSource
=
"{Binding Collection}"
/>
</
telerik:RadTreeListView.ChildTableDefinitions
>
</
telerik:RadTreeListView
>
</
Grid
>
MainWindow.xaml.cs
private
void
FrameworkPermissions_DataLoaded(
object
sender, EventArgs e)
{
GridViewDataColumn tempDataColumn =
new
GridViewDataColumn();
tempDataColumn.Header =
"Task"
;
tempDataColumn.EditTriggers = GridViewEditTriggers.CellClick;
tempDataColumn.DataMemberBinding =
new
Binding(
"TaskName"
) { Mode = BindingMode.TwoWay };
tempDataColumn.CellTemplate =
this
.Resources[
"dt"
]
as
DataTemplate;
...
}
Please let me know how this corresponds to your custom scenario.
Greetings,
Vanya Pavlova
the Telerik team
Thanks for the reply!
I tried with the solution that you have given,after setting EditTriggers Property to the GridViewDataColumn ,the check box is taking two Mouse clicks to check.Is there any otheway to check the CheckBox in a single Mouse Click.
Please help..
I strongly recommend you to review our online documentation that describes the RadGridView Event's lifecycle, please follow this link. Also you may find attached sample project that demonstrates the best approach to dynamically added columns.
I am waiting to hearing from you.
Vanya Pavlova
the Telerik team
Thanks for the reply!
I have written the code same as you wrote in your sample project.From your reply What i got to know is
1.To Check the ChekBox in a Cell ,it will take two mouse clicks 1 is to make cell editable another click is to check the check box.
2. If we check the parent row the child rows of the parent will not be selected/checked.
Is there anyway to select the all child rows by selecting a parent row.
Please Help...
Yes, you are correct. Due to the Selection you may use the built-in GridViewSelectColumn which you can add dynamically as it was demonstrated in my last project, however it will select only the parent node, not the children nodes in RadTreeListView. Furthermore selecting the children of a particular node through selecting it is not supported out of the box and you need to implement it on your own. I believe that the following forum thread would be helpful on that matter.
Vanya Pavlova
the Telerik team