This is a migrated thread and some comments may be shown as answers.

How do you define cardViewGroupItem1.Text?

2 Answers 89 Views
CardView
This is a migrated thread and some comments may be shown as answers.
Shin
Top achievements
Rank 1
Shin asked on 18 May 2018, 03:08 AM

Good morning.
I have checked the example source in Manual to use RadCardView.
First Group and Second Group are created,
I created one CardView Item in the First Group and two CardView Items in the Second Group.

I want to set the Title of each CardView Item to a different name.

For example, in First Group, the title of one CardView Item is "AA"
I would like to set the Title of one CardView Item in Second Group to "BB" and the title of another CardView Item to "CC".

Please check if this is possible.

 

 

        private void Form1_Load(object sender, EventArgs e)
        {
            this.radCardView1.Items.Add(new ListViewDataItem("First CardViewItem"));
            this.radCardView1.Items.Add("2", "Nancy", "Davolio", "507 - 20th Ave. E.Apt. 2A");            
            this.cardViewGroupItem1.Text = this.radCardView1.Items[1].Text;
            
            this.radCardView1.Items.Add("Third CardViewItem");

            ListViewDataItem item = this.radCardView1.Items[0];

            this.cardViewGroupItem1.Text = "CC";

            item[0] = "1";
            item["Column 1"] = "Andrew";
            item[radCardView1.Columns[2]] = "Fuller";
            item["Column 3"] = "908 W. Capital Way";

            this.radCardView1.EnableGrouping = true;
            this.radCardView1.ShowGroups = true;
            this.radCardView1.EnableCustomGrouping = true;
            this.radCardView1.CardViewElement.ViewElement.Orientation = Orientation.Vertical;
            this.radCardView1.Groups.Add(new ListViewDataItemGroup("First Group"));
            this.radCardView1.Groups.Add(new ListViewDataItemGroup("Second Group"));

            this.radCardView1.Items[0].Group = this.radCardView1.Groups[0];            
            this.radCardView1.Items[1].Group = this.radCardView1.Groups[1];            
            this.radCardView1.Items[2].Group = this.radCardView1.Groups[1];
            
        }

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 18 May 2018, 11:15 AM
Hi Shin,

In this case, you need to use the CardViewItemFormatting event to set the groups text. Here is an example that shows how you can get the group item and set the text from the data item:
private void RadCardView1_CardViewItemFormatting(object sender, CardViewItemFormattingEventArgs e)
{
    var visualItem = e.VisualItem as CardListViewVisualItem;
    var groupItem = visualItem.CardContainer.Items[0] as CardViewGroupItem;
    var groupText = visualItem.Data["Column 0"];
    groupItem.Text = "Test " + groupText;
}

Please note that there are two kinds of grouping in this case. The one used for all items and the one used inside the card. By default, all cards have a single group. And we are using a single card as a template for building all items. This is why you need to dynamically set the text.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shin
Top achievements
Rank 1
answered on 21 May 2018, 08:47 AM
Thank you very much. I didn't know there was a cardcontainer. Thanks to the detailed explanation, it was solved.
Tags
CardView
Asked by
Shin
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Shin
Top achievements
Rank 1
Share this question
or