How to hide row data of two gridviews?

0 Answers 31 Views
GridView
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Psyduck asked on 05 Jan 2022, 09:39 AM | edited on 05 Jan 2022, 09:48 AM

Hello.

There are two gridviews.

These gridviews are connected 1:1 with the row.
So I'm done with the vertical scrolling synchronization.

All data is now displayed.
When I check here, I want to show the contents of the gridview on the other side.

When the GridView Checkbox Column is unchecked, I want to make it impossible to see the contents of the grid view on the other side.

This should be done with Rows only and not all data.

What method do you have?

I attach an example.

In case of additional scroll sync, it is written as a code-behind. Can you change this to MVVM pattern?(How to get 2 gridview parameters since EventToCommandBehavior event is loaded?)

Thanks.

Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
commented on 07 Jan 2022, 09:02 AM

I have found a solution!

But there are two problems.
1. It doesn't work when I call element name from another gridview.
2. If I try to work on the same gridview, the Visible works, but it doesn't update immediately. If you scroll down and up, it will be updated.


<telerik:GridViewDataColumn header ...>
	<telerik:GridViewDataColumn.CellStyle>
		<Style TargetType="telerik:GridViewCell">
			<Setter Property="Visibility" Value="{Binding ... converter ... }" />
		</Style>
	</telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>

Martin Ivanov
Telerik team
commented on 07 Jan 2022, 10:50 AM

Working directly with the visual elements is not recommended in RadGridView. This is because of the UI virtualization and the fact that the same GridViewCell instance can represent different data items. For example, at some point the cell visual can draw "Item 1" and after you scroll, the cell visual can draw lets say "Item 10". To avoid those situations only data bindings to the underlying row's data item are recommended. Also, changing the Visibility of the GridViewCell visual is not recommended, because its size is used in different calculations related to the layout. In other words, if you hide the cell it is possible to break the layout system of the control in some situations.

In addition to this, the ElementName binding will work only in the same scope where both elements (source and target) are defined. So, you should not be able to use ElementName to access visual elements that are outside of the DataTemplate or Style where this type of binding is used.

About the requirement at hand, I am not sure that I understand it properly. Can you describe what exactly should happen to the right side RadGridview when you check a CheckBox in the "Is" column of the left side RadGridView?

As for the scrolling sync logic in code behind, this doesn't fall into the MVVM pattern scope, so you cannot write in an MVVM manner. The logic requires you to work with view logic purely, no model or view models are involved (Model-View-ViewModel). If you want to make the code-behind code reusable and remove it from the code-behind file, you can consider moving it to an attached property set to both GridView instance. Or alternatively, you can create a Blend behavior that can be set on both GridViews.

 

 

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Share this question
or