简体   繁体   中英

when button clicked show a jquery datatable modal dialog box not working

I have a table("sqlresultsactive") generated on page load. when I click a button "btnSelectProduct" on that page it shows a modal dialog box which contains that table.

In script I used jquery table before & after

$(document).ready(function () {
    $('#sqlresultsactive').DataTable();
}); 

<asp:GridView ID="sqlresultsactive" runat="server" CssClass="table table-striped table-bordered table-hover" Width="100%" ShowHeaderWhenEmpty="true" ClientIDMode="Static" AutoGenerateColumns="false" Font-Size="10px" OnRowCommand="sqlresultsactive_RowCommand" OnRowDataBound="sqlresultsactive_RowDataBound">
  <Columns>
    <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="10%">
      <ItemTemplate>
          <asp:Button ID="ButtonSelect" class="btn btn-success btn-sm p-0" runat="server" Width="60px" CommandName="SwitchProduct" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "webuniqueid") %>' Text="Select"></asp:Button><%--data-dismiss="modal"--%>
          <asp:HiddenField ID="BusinessSegment" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "BusinessSegment") %>' />
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Product" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="20%">
      <ItemTemplate>
        <asp:Label ID="lblProduct" runat="server" Text='<%#FormatStringValues(Container.DataItem("programName").ToString, "string")%>' CssClass="nobr"></asp:Label>
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Premium Finance" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="20%">
      <ItemTemplate>
        <%--<div id="tdHeadPremiumFinance">--%>
        <div align="center" id="tdPremiumFinance" runat="server">
            <asp:CheckBox ID="PremiumFinanceCheckBox" CssClass="checkbox" Visible="false" runat="server" />
            <asp:Label ID="PremiumFinanceWebUniqueId" runat="server" Text='<%#FormatStringValues(Container.DataItem("webuniqueid").ToString, "string")%>' Visible="false" CssClass="nobr"></asp:Label>
        </div>
        <%--</div>--%>
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Company" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="30%">
      <ItemTemplate>
        <span><%#SplitCompany(FormatStringValues(Container.DataItem("company").ToString, "string"), "Company")%></span>
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Dealer" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="20%">
      <ItemTemplate>
        <asp:Label ID="dealerLabel" runat="server" Text='<%#FormatStringValues(Container.DataItem("dealernumber").ToString, "string")%>' CssClass="nobr"></asp:Label>
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>

on document and added their source files but still it does not works. the table is shown but pagination and grid search etc.. are not showing

I hope that it will work after following change

$('#sqlresultsactive').DataTable({
  **"dom": "lrBftip",**
});

Another Option you can try: on button click then bind the DataTable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM