Hi,
I'm using the recursive selection feature which works fine so far, but for rows in my TreeList which aren't selectable it has some drawbacks.
If I use the recursive selection feature, these rows are highlighted too. It would be totally sufficient if these rows weren't highlighted (being in the SelectedRows list is ok - I can filter them out). How can I alter the Row so it isn't highlighted?
Thanks!
I'm using the recursive selection feature which works fine so far, but for rows in my TreeList which aren't selectable it has some drawbacks.
private
void
TreeListItemDataBound(
object
sender, TreeListItemDataBoundEventArgs e)
{
var item = e.Item
as
TreeListDataItem;
if
(item !=
null
)
{
if
(myCondition)
{
item[
"Select"
].Controls[0].Visible =
false
;
}
}
}
If I use the recursive selection feature, these rows are highlighted too. It would be totally sufficient if these rows weren't highlighted (being in the SelectedRows list is ok - I can filter them out). How can I alter the Row so it isn't highlighted?
Thanks!
5 Answers, 1 is accepted
0
Hi,
I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.
Looking forward for your reply.
Regards,
Radoslav
Telerik
I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.
Looking forward for your reply.
Regards,
Radoslav
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
JP
Top achievements
Rank 1
answered on 27 Feb 2015, 09:56 AM
Hello,
I did not receive an example. Is it supposed to be delived by mail? Maybe you could post the link in this thread.
Thanks!
I did not receive an example. Is it supposed to be delived by mail? Maybe you could post the link in this thread.
Thanks!
0
Hi,
It seems that something happened with the attachment I will contact our admins in order to investigate the case. At a meaning I am putting here the code from the attached project:
Please check it out and let me know if it helps you.
Looking forward for your reply.
Regards,
Radoslav
Telerik
It seems that something happened with the attachment I will contact our admins in order to investigate the case. At a meaning I am putting here the code from the attached project:
<
telerik:RadTreeList
ID
=
"RadTreeList1"
AllowRecursiveSelection
=
"true"
runat
=
"server"
OnNeedDataSource
=
"RadTreeList1_NeedDataSource"
DataKeyNames
=
"ID"
ParentDataKeyNames
=
"TypeID"
AutoGenerateColumns
=
"false"
AllowMultiItemSelection
=
"true"
>
<
Columns
>
<
telerik:TreeListSelectColumn
HeaderStyle-Width
=
"38px"
>
</
telerik:TreeListSelectColumn
>
<
telerik:TreeListBoundColumn
DataField
=
"ID"
HeaderText
=
"SportID"
HeaderStyle-Width
=
"80px"
UniqueName
=
"ID"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
DataField
=
"Name"
HeaderText
=
"Sport"
UniqueName
=
"Name"
></
telerik:TreeListBoundColumn
>
</
Columns
>
</
telerik:RadTreeList
>
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
RadTreeList1.PreRender += RadTreeList1_PreRender;
}
void
RadTreeList1_PreRender(
object
sender, EventArgs e)
{
foreach
(var item1
in
RadTreeList1.Items)
{
var item = item1
as
TreeListDataItem;
if
(item !=
null
)
{
DataRowView view = item.DataItem
as
DataRowView;
if
(Convert.ToInt32(view[
"ID"
].ToString()) > 4)
{
item.FindControl(
"columnSelectCheckBox"
).Visible =
false
;
item.Selected =
false
;
}
}
}
}
protected
void
RadTreeList1_NeedDataSource(
object
sender, TreeListNeedDataSourceEventArgs e)
{
DataTable table =
new
DataTable();
table.Columns.Add(
"ID"
,
typeof
(
int
));
table.Columns.Add(
"Name"
);
table.Columns.Add(
"TypeID"
,
typeof
(
int
));
table.Rows.Add(1,
"Winter"
,
null
);
table.Rows.Add(2,
"Summer"
,
null
);
table.Rows.Add(3,
"Biathlon"
, 1);
table.Rows.Add(4,
"Figure skating"
, 1);
table.Rows.Add(5,
"Alpine skiing"
, 1);
table.Rows.Add(6,
"Ski jumping"
, 1);
table.Rows.Add(7,
"Basketball"
, 2);
table.Rows.Add(8,
"Boxing"
, 2);
table.Rows.Add(9,
"Swimming"
, 2);
table.Rows.Add(10,
"Volleyball"
, 2);
table.Rows.Add(11,
"Wrestling"
, 2);
table.Rows.Add(12,
"Cycling"
, 2);
(sender
as
RadTreeList).DataSource = table;
}
Please check it out and let me know if it helps you.
Looking forward for your reply.
Regards,
Radoslav
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
JP
Top achievements
Rank 1
answered on 04 Mar 2015, 01:18 PM
Hello,
thanks for your response. Unfortunately, this doesn't solve my problem correctly.
The rows without checkbox are correctly deselected, but the parents are deselected too.
I think this is because of the recursive selection: If I select a top node, all child rows are selected. By deselecting (Selected=false) one child row in PreRender, the parent will be deselected too.
But I want the parent row to stay selected.
How can I achieve this?
Thanks!
thanks for your response. Unfortunately, this doesn't solve my problem correctly.
The rows without checkbox are correctly deselected, but the parents are deselected too.
I think this is because of the recursive selection: If I select a top node, all child rows are selected. By deselecting (Selected=false) one child row in PreRender, the parent will be deselected too.
But I want the parent row to stay selected.
How can I achieve this?
Thanks!
0
Hello,
Unfortunately the desired functionality cannot be achieved by using the build in recursive selection. This is a custom requirement and you need to implement your logic manually. I suggest you to use the
TreeListTemplateColumn with check boxes in ItemTemplate and HeaderTemplate. Then you can traverse the items on PreRender event and check the checboxes based on your requirements.
I hope this helps.
Regards,
Radoslav
Telerik
Unfortunately the desired functionality cannot be achieved by using the build in recursive selection. This is a custom requirement and you need to implement your logic manually. I suggest you to use the
TreeListTemplateColumn with check boxes in ItemTemplate and HeaderTemplate. Then you can traverse the items on PreRender event and check the checboxes based on your requirements.
I hope this helps.
Regards,
Radoslav
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.