2016-08-11 18 views
1

同じascxページに2つのjQueryデータ型があります。私は、ツールバーのdivに、テーブルがレンダリングされた後のコードでリンクを呼び出すハイパーリンクを挿入しようとしています。ここでは、コードです:同じページの複数のjQueryデータ型

  var SDFtable = $('#tblSDF').dataTable(
      { 
       "scrollY": "300px", 
       "scrollX": true, 
       "scrollCollapse": true, 
       "paging": false, 
       "autowidth": true, 

       dom: '<"toolbar"><"filterPad"f>rti<"floatRight"B><"clear">', 

       //all available button options 
       //'copy', 'csv', 'excel', 'pdf', 'print' 

       buttons: { 
        buttons: [ 
         { extend: 'excel', text: 'Download this grid in Excel', exportOption: { page: 'current' }, footer: true } 
        ] 
       } 

      }); 

      $("div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>'); 

問題は、私は、コードのこれらのブロックの2、各テーブルに1つを持っているということであり、第二$(「div.toolbar」)の行が実行されるとき、それは両方にそのリンクを追加しますデータテーブル。どのようにその特定のテーブルを描画されて参照することができますか?

ありがとうございます。

+0

は、あなたのテーブルの両方が '#のtblSDF'のIDを持っていますか? –

+0

おそらく、これは役立つかもしれません。http://stackoverflow.com/questions/7827986/multiple-datatables-on-the-same-page-with-different-ajax-sources – morne

答えて

1

はこれを試してみてください。

$("#tblSDF_wrapper div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>'); 
+0

これは、まだjQuery要素のトラバーサルを拾いました、ありがとう手伝い! – TrevorGoodchild

1

はこれを試してみてください:

$('#tblSDF').find("div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>'); 
+0

ありがとう、これは正しい方向に私を得た – TrevorGoodchild

関連する問題