Telerik Forums
UI for ASP.NET MVC Forum
2 answers
65 views

Hi,

I am trying to create logic to allow clicking in the Badge, based on the recommendations in https://www.telerik.com/forums/badge-click-to-execute-code-in-controller-class, to run code in the Controller but needs some direction. 

The Controller is called (using ajax call in example 1) when clicking on "Get total" (in example 2) but what to use in the badge to make it execute? Not the name of it, right? (already tried this and nothing happens...)

 

Please describe on how to invoke the ajax call from a badge or tell me if badges cannot  be used in this way. I would also like to know the rationale in not embedding native click logic to the badge. I mean, if showing an aggregated value of something, why wouldn't you want to link to the data the value is calculated from?

 

 

 

 

 

 

Example 1

<script>
    $("#badge-total").click(function () {
        $.ajax({
        url: '@Url.Action("ShowTotalGrid")', 
        dataType: "json", 
        type: "POST", 
        contentType: 'application/json; charset=utf-8', 
        cache: false, 
        data: {}, 
        success: function (data) {           
            if (data.success) {
                alert(data.message);
            }
        },
        error: function (xhr) {
            alert('error');
        }
    });
});
</script>

 

 

Example 2

<div id="badge-total">
    Get total
</div>

 

/Regards Anders

Anders
Top achievements
Rank 1
Veteran
Iron
 answered on 24 Feb 2021
5 answers
135 views

Hi,

 

I have Badges that display different sums of data. I would like to filter a Grid based on clicking a them.

Is it possible to execute code in Controller class when clicking on a Badge, or do I have to rethink this? Can you please point me in the right direction?

Regards, Anders

 

 

Anders
Top achievements
Rank 1
Veteran
Iron
 answered on 23 Feb 2021
3 answers
303 views
Trying to find a simple example of a badge where it is overlaying an icon, not next to a button etc.  A badge example similar to every other "badge" on the web.  Even on this Telerik site, the shopping cart with the "0" items badge overlaid on top.
Georgi Denchev
Telerik team
 answered on 18 Sep 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?