Declined
Last Updated: 05 Aug 2016 13:09 by ADMIN
ADMIN
Hristo
Created on: 30 May 2016 13:14
Category: ListView, CardView and CheckedListBox
Type: Bug Report
0
FIX. RadCardView - CardViewGroupItems are still expanded not respecting its IsExpanded property which is set to false.
How to reproduce: Bind RadCardView to the Employees table from the Northwind database:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        this.radCardView1.CardViewItemCreating += radCardView1_CardViewItemCreating;
    }

    private void radCardView1_CardViewItemCreating(object sender, Telerik.WinControls.UI.CardViewItemCreatingEventArgs e)
    {
        CardViewGroupItem group = e.NewItem as CardViewGroupItem;
        if (group != null)
        {
            group.IsExpanded = false;
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        this.employeesTableAdapter.Fill(this.nwindDataSet.Employees);
    }
}

Workaround: handle the CardViewItemFormatting event
private void radCardView1_CardViewItemFormatting(object sender, CardViewItemFormattingEventArgs e)
{
    CardViewGroupItem group = e.Item as CardViewGroupItem;
    if (group != null && group.Tag == null && group.Parent != null && group.Parent.Parent != null && group.Parent.Parent is CardListViewVisualItem)
    {
        group.IsExpanded = false;
        group.Tag = "Processed";
    }
}
1 comment
ADMIN
Ralitsa
Posted on: 05 Aug 2016 13:09
RadCardView supports multiple layouts and a single visual item can contain several group items. The function of a group items is to organize LayoutControlItemBaseItems into the VisualItem. Data items do not know how many group items are contained in the visual item and this is why they do not have a corresponding property. If the user wants to start the CardView with all group items(in our case we have only one group item per visual item) collapsed the following solution is available:
The CardViewItemCreating event is not suitable to achieve this, due to the items virtualization in RadCardView and only items that can be shown on the screen will be created and then when the user scrolls the items will be reused.
The easiest way to implement this is using a HashSet<ListViewDataItem>. The code below shows this approach:

private HashSet<ListViewDataItem> shownItems = new HashSet<ListViewDataItem>();
private void radCardView1_CardViewItemFormatting(object sender, CardViewItemFormattingEventArgs e)
{
CardViewGroupItem groupItem = e.Item as CardViewGroupItem;
if (groupItem != null)
{
if (!this.shownItems.Contains(e.VisualItem.Data))
{
groupItem.IsExpanded = false;
this.shownItems.Add(e.VisualItem.Data);
}
}
}