1

I have two jQuery datatables on the same ascx page. I'm trying to insert a hyperlink into the toolbar div, which calls a link in the code behind, after the table has been rendered. Here's the code:

           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>');

The problem is that I have two of these blocks of code, one for each table, and when the second $("div.toolbar") line runs, it adds that link to both datatables. How can I reference that specific to the table that is being drawn?

Thanks in advance.

2
  • Do both of your tables have an ID of #tblSDF? Commented Aug 11, 2016 at 12:31
  • Maybe this might help stackoverflow.com/questions/7827986/… Commented Aug 11, 2016 at 12:35

2 Answers 2

1

try this:

$("#tblSDF_wrapper div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel"  runat="server">SDF Pool</a></h2>');
Sign up to request clarification or add additional context in comments.

1 Comment

Got it, still picking up on jQuery element traversal, thanks for the help!
1

Try this:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.