I’m writing a Dashboard Application in C#, using DevExpress components. I am trying to dynamically create a circular gauge, and update the gauges value using a callback function. In the DevExpress sample here:
http://demos.devexpress.com/ASPxGaugesDemos/Gauges/CircularGauge.aspx
They show how to update a gauge that has already been added to the form at design time. One of the calls in their sample has var gague = window[gaugeName]
When I make the call to this function the value comes back undefiend:
function PerformCallbackCore(gaugeName) {
var gauge = window[gaugeName];
m_isDirty = gauge.InCallback();
if (!m_isDirty)
gauge.PerformCallback();
}
Does anyone possibly know why I cannot retrieve the gauge value?
Thanks – Larry
It is due to bad code in the gauge demo. Yes, I use (and pay for) DX; I can say that.
The code uses
setTimeoutwith a string (enough ick here!) and passes in the “name” of window property assigned to the control withClientInstanceName(the code won’t work if the name used and this don’t match up). The demo code is further confusing/ugly by having a different “proxy” function for Gauge1 … GaugeN.Now, I suspect that the
ClientInstanceNamewasn’t used or the correct name wasn’t passed somewhere, sowindow[aPropertyName]evaluates to undefined, however .... a better way to write it would be to use/pass the object directly instead of relying on the artificial “client name” / window property. See
ASPxClientGaugeControl (and follow links to the appropriate handler) and consider this:
With a single unified callback (and distinct lack of “client names” and useless proxy methods):
Happy coding!