TelerikCard Click

1 Answer 25 Views
Card
Igor
Top achievements
Rank 1
Igor asked on 17 May 2024, 09:44 AM

Hi there,

Is there a way to handle  the click anywhere on TelerikCard without wrapping it with a div and handling div.onclick?

 

Regards,

Igor

1 Answer, 1 is accepted

Sort by
0
Accepted
Svetoslav Dimitrov
Telerik team
answered on 22 May 2024, 05:39 AM

Hello Igor,

I can confirm that wrapping the TelerikCard in a <div> with an onclick event is the best way to achieve the desired behavior. 

Regards,
Svetoslav Dimitrov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Igor
Top achievements
Rank 1
commented on 22 May 2024, 06:59 AM

Can we have a way to handle OnClick out of the box in the future releases? (w/o wrapping manually)
Svetoslav Dimitrov
Telerik team
commented on 24 May 2024, 11:44 AM

Hello Igor,

What do you expect an OnClick on the <TelerikCard> to do more than what you can already achieve by wrapping the <TelerikCard> in a <div @onclick>?

Igor
Top achievements
Rank 1
commented on 27 May 2024, 11:06 AM

Hello Svetoslav,

I don't expect anything more. I just want to avoid wrapping it manually every time I need it. It's much simpler and more readable, convenient to have <TelerikCard OnClick="@..."> rather than <div @onclick="@..."><TelerikCard> ........

Svetoslav Dimitrov
Telerik team
commented on 29 May 2024, 11:51 AM

Hello Igor,

You can wrap the TelerikCard, wrapped in a <div @onclick> in a custom component and expose parameters to make an easily reusable component (extract more parameters as needed):

<div @onclick="@OnCardClick">
    <TelerikCard Width="@CardWidth">
        <CardHeader>
            <CardTitle>@CardHeaderTitle</CardTitle>
        </CardHeader>
        <CardImage Src="@CardImgSrc"></CardImage>
        <CardBody>
            <CardTitle>Rome</CardTitle>
            <CardSubTitle>Capital of Italy</CardSubTitle>
            <CardSeparator></CardSeparator>
            <p>
                Rome is a sprawling, cosmopolitan city with nearly 3,000 years of globally influential art, architecture and culture on display.

                Ancient ruins such as the Forum and the Colosseum evoke the power of the former Roman Empire.
            </p>
        </CardBody>
        <CardActions Layout="@CardActionsLayout.Stretch">
            <TelerikButton Class="k-flat" Icon="@SvgIcon.HeartOutline" Title="Like"></TelerikButton>
            <TelerikButton Class="k-flat" Icon="@SvgIcon.Comment" Title="Comment"></TelerikButton>
            <TelerikButton Class="k-flat">Read More</TelerikButton>
        </CardActions>
        <CardFooter>
            <span style="float:left">Created by @@john</span>
            <span style="float:right">March 05, 2021</span>
        </CardFooter>
    </TelerikCard>
</div>

@code {
    [Parameter]
    public EventCallback<MouseEventArgs> OnCardClick { get; set; }
    [Parameter]
    public string CardWidth { get; set; }
    [Parameter]
    public string CardHeaderTitle { get; set; }
    [Parameter]
    public string CardImgSrc { get; set; }
}

I can confirm that we have no intention of adding an OnClick event to the whole Card.

Tags
Card
Asked by
Igor
Top achievements
Rank 1
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or