问题描述:

In the Kendo documentation there are examples of binding many charts to local data, but there is nothing for the radial gauge.

Can anyone tell me how to specify the value for the pointer using an int in my controller?

<div id="gauge-container">

@(Html.Kendo().RadialGauge()

.Name("gauge")

.Pointer(pointer =>pointer.Value(intFromController) )

.Scale(scale => scale

.MinorUnit(5)

.StartAngle(-30)

.EndAngle(210)

.Max(180)

)

)

</div>

EDIT -- For anyone who arrives here with the same issue here is how I fixed it(actual code edited with test function to simplicity, also sorry for indenting, in a rush.):

View:

<script>

$(document).ready(function () {

$.ajax({

type: "POST",

cache: false,

url: 'test/',

success: function (data) {

$("#gauge").data("kendoRadialGauge").value(data);

}

})

})</script>

@(Html.Kendo().RadialGauge()

.Name("gauge")

.Pointer(pointer => pointer.Value(0))

.Scale(scale => scale

.MinorUnit(5)

.StartAngle(-30)

.EndAngle(210)

.Max(180)

)

)

Controller

public double test()

{

double value = 10;

return value;

}

网友答案:

In Action of The Controller you can set:

ViewData["myAngle"] = 123;

And in View, you can use it in such way:

<div id="gauge-container">
@(Html.Kendo().RadialGauge()
    .Name("gauge")
    .Pointer(pointer =>pointer.Value(@ViewData["myAngle"]) )
    .Scale(scale => scale
        .MinorUnit(5)
        .StartAngle(-30)
        .EndAngle(210)
        .Max(180)
    )
)
</div>
相关阅读:
Top