Fill via controller gauge

5 posts, 1 answers
  1. Chili
    Chili avatar
    46 posts
    Member since:
    Aug 2018

    Posted 06 Nov 2018 Link to this post

    Hello,

    Is it possible to fill my gauge through my controller?

    In a bar chart you can do for example:

    .DataSource(ds => ds.Read(read => read.Action("CNTRLLERFUNC", "CNTRLLERNANE")))

    How can I perform this for in a gauge? And I don't want this to be done through a model.

  2. Chili
    Chili avatar
    46 posts
    Member since:
    Aug 2018

    Posted 07 Nov 2018 Link to this post

    I have at the moment an ajax thing but I cant fill the value of the gauge....

    $.ajax({
            type: "GET",
            url: '/Home/FillG', // 'ControllerName/ActionName'
            //dataType: "json",
            success: function (data) {
                var fill = document.getElementById("gauge");
                fill.value = data;
            },
            error: function () {
     
            }
        });
    .Pointer(pointer => pointer.Value(0).Color("black")) //Get value of controller / ajax
  3. Answer
    Eyup
    Admin
    Eyup avatar
    4046 posts

    Posted 07 Nov 2018 Link to this post

    Hello,

    Generally, you can configure the Pointer and Scale of the Kendo radial gauge, however, I'm afraid setting it to a data action directly is not provided out-of-the-box:
    https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/radialgauge
    https://docs.telerik.com/kendo-ui/controls/gauges/radialgauge/overview

    Here are 3 options you can try:

    1. AJAX request - you can slightly modify your sample to apply Kendo syntax:
    https://stackoverflow.com/questions/12342590/kendo-gauge-bind-to-xml-json-datasource

    2. Use the change event handler of a separate Kendo data source widget on the page:
    https://www.telerik.com/forums/how-can-i-set-the-gauge-value-by-datasource

    3. Try to pass the value in the ViewData:
    https://stackoverflow.com/questions/15882939/binding-a-kendo-gauge-to-local-data?rq=1

    I hope this will prove helpful.

    Regards,
    Eyup
    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.
  4. Chili
    Chili avatar
    46 posts
    Member since:
    Aug 2018

    Posted 07 Nov 2018 in reply to Eyup Link to this post

    Dear Eyup,

    Thanks for your well written reply!

    To what do i need to change the .value(data.value); ?

    My code:

    public int FillG()
            {
                var x = 5;
                return x;
    }
     
    $.ajax({
            type: "GET",
            url: '/Home/FillGauge', // 'ControllerName/ActionName'
            //dataType: "json",
            success: function (data) {
                $("#gauge").data("kendoRadialGauge").value(/*what needs this to be*/);
            },
            error: function () {
     
            }
        });
  5. Chili
    Chili avatar
    46 posts
    Member since:
    Aug 2018

    Posted 07 Nov 2018 in reply to Chili Link to this post

    Got it!.
Back to Top