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

Remove Expand/Collapse from CardView

7 Answers 240 Views
CardView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 27 Jun 2018, 10:44 PM

How do I get rid of the Expand / Collapse on Each card? (See Capture1)

Also, it might be related, but I would like the photo to expand to fill to the top and side edges in the card, as in the Telerik UI for WinForms demo application. (See Capture2).

I copied this Demo code exactly, even editing the form1.Designer.vb, so they should look the same, but I still get variations between the two.   In designer editing properties directly, it will not hold several properties, changing them to what the control thinks they should be.  This is especially true for trying to set the size and location of the CardViewItems.

Please advise.

Thanks,

 

 

7 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 28 Jun 2018, 09:38 AM
Hi Mark,

Since we are using UI Virtualization you can access the items in the CardViewItemFormatting event. The following snippet shows how you can hide the group header and set the padding:
private void RadCardView1_CardViewItemFormatting(object sender, Telerik.WinControls.UI.CardViewItemFormattingEventArgs e)
{
    var visualItem = e.VisualItem as CardListViewVisualItem;
    visualItem.Padding = new Padding(0);
  
    var groupItem = visualItem.CardContainer.Items[0] as CardViewGroupItem;
    groupItem.Padding = new Padding(0);
  
    groupItem.HeaderElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
  
    CardViewItem item = e.Item as CardViewItem;
    if (item != null && item.FieldName == "MyImage")
    {
        item.DrawText = false;
        item.EditorItem.ImageLayout = ImageLayout.Stretch;
    }
  
}

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
Mark
Top achievements
Rank 1
answered on 28 Jun 2018, 10:16 PM

Excellent!

Thanks for the prompt response.

0
HarisB
Top achievements
Rank 1
answered on 23 Apr 2019, 04:13 PM

Hello,

how I read data from selected cardview item ? SelectedItemChanged or SelectedIndexChanged ? Please example.

Best regards,

HB

0
Dimitar
Telerik team
answered on 24 Apr 2019, 08:29 AM
Hi Haris,

Both events are suitable, here is how you can get the data from the selected item:
private void RadCardView1_SelectedItemChanged(object sender, EventArgs e)
{
    var data = radCardView1.SelectedItem.DataBoundItem as DataModel;
    Console.WriteLine(data.Name);
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
HarisB
Top achievements
Rank 1
answered on 24 Apr 2019, 12:12 PM

 

Hello,

Thanks for your reply. I did not work with DataModel, but CardView was filled dynamically through the loop. I worked on an example from the attachment.

this.radCardView1.Items.Add("a","b","c","d");

Best regards,

HB

0
Dimitar
Telerik team
answered on 24 Apr 2019, 12:59 PM
Hi Haris,

This will work if the control is bound to a data source. In your case you can directly access the data like this:
private void RadCardView1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (radCardView1.SelectedItem == null)
    {
        return;
    }
    var data = radCardView1.SelectedItem["Column 1"];
    Console.WriteLine(data);
}

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

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
HarisB
Top achievements
Rank 1
answered on 24 Apr 2019, 01:34 PM

Excellent!

Thanks a lot.

Best regards,

HB

Tags
CardView
Asked by
Mark
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Mark
Top achievements
Rank 1
HarisB
Top achievements
Rank 1
Share this question
or