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
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