Error (bug) in gridview row style visibility and AlternationCount

2 Answers 80 Views
General Discussions GridView
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Psyduck asked on 10 Jan 2022, 03:59 AM | edited on 10 Jan 2022, 04:05 AM
Hello.

This is similar to my most recent post.

Is the current example also not recommended? This is a row style using Visivility Hidden Converter.
I can see the opposite grid row when checked.

Here, I gave "AlternationCount" and the data is displayed with a gray background.

However, it is not visible when using the Search filter. (Visible when checked)

This seems like a bug.
Please confirm.

Thanks.

2 Answers, 1 is accepted

Sort by
1
Accepted
Dilyan Traykov
Telerik team
answered on 12 Jan 2022, 11:58 AM

Hello Psyduck,

Thank you for the provided project and image.

The reason for this behavior is that when the AlternationCount property is set, the AlternateRowStyle is used for the alternating rows while the RowStyle is used for the rest of the rows. In this particular scenario, the binding to the Visibility property of the rows will be evaluated only for every 2nd row.

In addition, to have the IsChecked property updated correctly, you need to set the Mode of the binding to TwoWay:

				<telerik:GridViewDataColumn Header="Is"	DataMemberBinding="{Binding IsChecked}" Width="60" HeaderTextAlignment="Center">
					<telerik:GridViewColumn.CellTemplate>
						<DataTemplate>
							<CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalAlignment="Center"/>
						</DataTemplate>
					</telerik:GridViewColumn.CellTemplate>
				</telerik:GridViewDataColumn>

As suggested by my colleague in this forum thread, however, it is advised to use filtering, rather than hide the rows via their Visibility property. You would need to ensure the view is reloaded when updating an item, though, as suggested in this thread: Update filter when property is changed in code.

For your convenience, I've updated the sample project to demonstrate both approaches. Please have a look and let me know if you find this helpful.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 13 Jan 2022, 01:19 AM

Hello.

 

Thanks for the example source and explanation.

If I do it my way, I think you can reset it in AlternatingRowStyle.

I also thought of filtering, but like my sample, it should be matched 1:1 with the data next to it.

For example, a row with Id=2 should display a matching grid from row 2 to another. So the filtering becomes ambiguous. (Scrolling is also synchronized with the grid and moves with it. (Not currently in sample)

If so, can I use the method I use?
The data is about 1 to 9999, so I don't think it's a lot.

Dilyan Traykov
Telerik team
commented on 17 Jan 2022, 09:44 AM

Hello, Psyduck,

If your current approach provides the expected result, you are free to go with it. I just wanted to share another possible approach in case you found it more suitable.

Nonetheless, do let me know if you come across any issues with this.
Tags
General Discussions GridView
Asked by
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Answers by
Dilyan Traykov
Telerik team
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Share this question
or