2

私はaspmvcアプリケーションに取り組んでいます。データベースからのデータに応じてチャートを作成しています。[移動]ボタンをクリックすると、dbから結果を取得してグラフ画像を設定するgetReportData()関数が呼び出されます。

初めて呼び出すと関数は正常に動作しますが、2回目はグリッドデータのみが表示されます。つまり、画像を生成する関数は2回目は呼び出されません。デバッグを試みましたが、2回目ではなく1回目だけデバッグポイントを取得しています。 。

  function getReportData() {
        //            debugger;
       //Enable wait Icon & disable others


       $('#span_bar_bg').css('display','none');
       $('#span_bar_wait').css('display','block');
       $('#span_bar_result').css('display','none');
       $('#span_pie_bg').css('display','none');
       $('#span_pie_wait').css('display','block');
       $('#span_pie_result').css('display','none');
       var report='ProductNameBatch';
       var subreport='Non-FaceBook';
        if( report.toLowerCase()=='ctss' )
        {
         alert('Report is temporarily Un-available');
         return;
        }

        if (parent.top.$("input#from_date").val() == "" ||  parent.top.$("input#to_date").val() == "") {
            alert("Invalid Date Range !!!");
            return;
        }


        $("#span_grid_bg").css('display','none');
        $("#span_grid_view").css('display', 'block');



           // "sScrollX": "100%",
           // "sScrollXInner": "101%",
           // "bScrollCollapse": true,


        $('#grid_view').dataTable({
            "bAutoWidth": true,
            "bServerSide": false,
            "sAjaxSource": "fetchGridReport?&from_date=" + parent.top.$("input#from_date").val() + "&to_date=" + parent.top.$("input#to_date").val() + "&report="+report+"&subreport="+subreport,
            "bProcessing": true,
            "bRetrieve": false,
            "bDestroy": true,
            "iDisplayLength": 17,
            "aoColumns": columnList
        });


         $('#grid_view').dataTable().fnAdjustColumnSizing();

        //Request for reports 

         debugger;
           $('#span_bar_result img[alt="Report by Country-Language"]').attr('src','/fetchChartReport?chartType=Bar&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' +parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Country-Language&displayformat=2&filterParamList=no');
           $('#span_pie_result img[alt="Report by Country-Language"]').attr('src','/fetchChartReport?chartType=Pie&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' + parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Country-Language&displayformat=2&filterParamList=no');

         debugger;
           $('#span_bar_result img[alt="Report by Response"]').attr('src','/fetchChartReport?chartType=Bar&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' +parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Response&displayformat=2&filterParamList=no');
           $('#span_pie_result img[alt="Report by Response"]').attr('src','/fetchChartReport?chartType=Pie&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' + parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Response&displayformat=2&filterParamList=no');

         debugger;
           $('#span_bar_result img[alt="Report by Resolved vs UnResolved"]').attr('src','/fetchChartReport?chartType=Bar&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' +parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Resolved vs UnResolved&displayformat=2&filterParamList=no');
           $('#span_pie_result img[alt="Report by Resolved vs UnResolved"]').attr('src','/fetchChartReport?chartType=Pie&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' + parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Report by Resolved vs UnResolved&displayformat=2&filterParamList=no');

         debugger;
           $('#span_bar_result img[alt="Turk Spend by Country($)"]').attr('src','/fetchChartReport?chartType=Bar&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' +parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Turk Spend by Country($)&displayformat=2&filterParamList=no');
           $('#span_pie_result img[alt="Turk Spend by Country($)"]').attr('src','/fetchChartReport?chartType=Pie&from_date=' + parent.top.$("input#from_date").val() + '&to_date=' + parent.top.$("input#to_date").val() +  '&report='+report+'&subreport='+subreport+'&reporttitle=Turk Spend by Country($)&displayformat=2&filterParamList=no');



        //register call back functionality invoked when result image response complete
         $('img[id^="img_barchart_result"]').bind('load',function(){
             onLoadComplete('bar');

         });

         $('img[id^="img_piechart_result"]').bind('load',function(){
              onLoadComplete('pie');
         });

    }

これが私の制御機能です

 public FileResult fetchChartReport(SeriesChartType chartType, string from_date, string to_date, string report, string subreport,string reporttitle,string displayformat, string filterParamList)
    {
        try
        {
            Chart chart = new Chart();
            string repportlistid = "chart-" + report.ToLower() + "-" + subreport.ToLower();
            //List<string> reportNameList=  GetParameterListById(repportlistid); 
            //return View();

            reportObject = getReportInstance(report);
            chart = reportObject.getChartReport(chartType, from_date, to_date, report.ToLower(), subreport.ToLower(), reporttitle,displayformat, filterParamList);

            MemoryStream ms = new MemoryStream();
            chart.SaveImage(ms);


            return File(ms.GetBuffer(), @"image/png");

        }
        catch (Exception ex)
        {
            return File(Server.MapPath(Url.Content("~/Content/dashboard/images/dash_no_data.jpg")), "image/jpg");
        }



    }

前もって感謝します

4

2 に答える 2

2

教皇、

これは、imgクリックを開始したときにDOMが変更されるため、バインドイベントハンドラーが吹き飛ばされます。代わりに、jquery .on()イベントハンドラーを使用してみてください。

http://api.jquery.com/on/

これは、.off()リクエストを発行するか、ページから移動するまでDOMが更新されても、イベントハンドラーが保持されるという点で、古いjquery .live()イベントと同じように機能します。

于 2012-05-24T10:21:07.727 に答える
1

ここでURLに問題があると思います '/fetchChartReport?chartType=Pie' ここで適切なコントローラーとアクション名を指定する必要があります。別のページ「fetchGridReport」から投稿する場合は、以下のように非表示フィールドからURLを取得することをお勧めします。

var url = $( "#hdnChartUrl")。val();

$('#span_bar_result img [alt = "Report by Resolved vs UnResolved"]')。attr('src'、url +'?chartType = Bar&from_date ='+ parent.top。$( "input#from_date")。val ()+'&to_date ='+ parent.top。$( "input#to_date")。val()+'&report ='+ report +'&subreport ='+ subreport +'&reporttitle = Report by Resolved vs UnResolved&displayformat = 2&filterParamList = no' );

ここで、URLが動的に追加されることを確認してください。

于 2012-05-24T10:25:05.740 に答える