Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 388 - [TW77012763] Using attached example, ClickLegend event needs to have AutoPostBack ...
Summary: [TW77012763] Using attached example, ClickLegend event needs to have AutoPost...
Status: IN_PROGRESS
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: WebChart (show other bugs)
Version: unspecified
Hardware: All All
: High enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-23 13:32 EST by narcís calvet
Modified: 2014-06-11 10:28 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments
Clientside Javascript code to actuate postback without AutoPostback active. (2.22 KB, application/zip)
2014-06-11 10:21 EDT, marc meumann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description narcís calvet 2013-11-20 11:26:58 EST
Using attached example, ClickLegend event needs to have AutoPostBack set to True or otherwise it isn't fired. But after it was set to True, I need to double click the checkbox to check/uncheck it because the WebChart1_ClickLegend event will fire twice!

Besides, I need to disable the AutoPostBack because if it was enable, when I click on the series to "drill down" (this is another feature of my tool), it will "drill down" twice.
Also, it happens without ClickLegend event, only using checkboxes = true.  For check last point you can see this post
http://www.teechart.net/support/viewtopic.php?f=4&t=11733&p=50767#p50767
It still happens in last version of TeeChart.Net.
  [created:2008-01-23T13:32:10.000+01:00 reported by:narcis@steema.com reported in version:Build 3.5.3065.19160 (TeeChart for .NET)]
Comment 1 marc meumann 2014-06-11 10:21:30 EDT
Created attachment 229 [details]
Clientside Javascript code to actuate postback without AutoPostback active.

Zip includes a webform page with TeeChart on it and code behind to respond to Legend checkbox clicks.
Comment 2 marc meumann 2014-06-11 10:28:19 EDT
Postback can be controlled by clientside Javascript. See the attached zipfile example ExampleCustomPostback.zip.

We'll look to incorporating this into the product to that it won't be necessary to add/write this code in the future. Changed to feature request

webform code (add this into the page header area):
=============
<script type="text/javascript">

    var is_ie = navigator.appName == 'Microsoft Internet Explorer';

    this.getLocation = function (chObj) {

        var dynaObj = chObj;
        var overallTop = 0;
        var overallLeft = 0;
        if (is_ie) {
            var objb = dynaObj.getBoundingClientRect();
            overallLeft += objb.left;
            overallTop += objb.top;
        }
        else
            while (dynaObj.offsetParent) {
                overallTop = overallTop + dynaObj.offsetTop;
                overallLeft = overallLeft + dynaObj.offsetLeft;
                dynaObj = dynaObj.offsetParent;
            }
        if ((chObj.style.position != "absolute") || (chObj.style.posTop == null)
												 || (chObj.style.top == "")) {
            chObj.style.posTop = overallTop;
        }
        if ((chObj.style.position != "absolute") || (chObj.style.posLeft == null)
												 || (chObj.style.left == "")) {
            chObj.style.posLeft = overallLeft;
        }
    }

    this.activatePostback = function (chart, evt) {
        evt = (evt) ? evt : event;
        var oVDiv = document.getElementById(chart);
        if ((oVDiv.style.position != "absolute") || (oVDiv.style.posTop == null)
                                                 || (oVDiv.style.top == "")
                                                 || (oVDiv.style.posLeft == null)
                                                 || (oVDiv.style.left == "")) {
            getLocation(oVDiv);
        }

        var eClientX;
        var eClientY;
        var xPos;
        var yPos;
        var scrollOffsetX;
        var scrollOffsetY;
        eClientX = evt.clientX;
        eClientY = evt.clientY;
        if (is_ie) {
            event.cancelBubble = true;
            scrollOffsetX = iebody.scrollLeft;
            scrollOffsetY = iebody.scrollTop;
        }
        else {
            evt.cancelBubble = true;
            scrollOffsetX = window.pageXOffset;
            scrollOffsetY = window.pageYOffset;
        }
        xPos = eClientX + scrollOffsetX;
        yPos = eClientY + scrollOffsetY;
        if (is_ie) {
            __doPostBack(chart, 'chart$' + chart + ';xPos$'
                                       + (eClientX - oVDiv.style.posLeft) + ';yPos$'
                                       + (eClientY - oVDiv.style.posTop));
        }
        else {
            __doPostBack(chart, 'chart$' + chart + ';xPos$'
                                       + (xPos - oVDiv.style.posLeft) + ';yPos$'
                                       + (yPos - oVDiv.style.posTop));
        }
    }


</script>

=============

Retouch the TeeChart declaration on the page, add onclick="activatePostback('WebChartName',event)"

=============
<tchart:WebChart ID="WebChart2" onclick="activatePostback('WebChart2',event)" runat="server" TempChart="Session" AutoPostback="False" OnClickLegend="WebChart2_ClickLegend" Height="300px" Width="400px" />
=============