Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:37:46+00:00 2026-05-23T19:37:46+00:00

I am using jQuery templates and the dataTables plug-in to create grids in my

  • 0

I am using jQuery templates and the dataTables plug-in to create grids in my application. In all cases I invoke an ASMX web service via an ajax call and in the callback function I render the output using the tmpl command and then finally apply the dataTables plug-in to the generated table. I’m having difficulties in updating the dataTables grid after deleting, inserting or updating to show the changes and the docs have not been much help. Has anyone else done anything similar to this? What is the best way to update my grid display?

TEMPLATE CODE

<script id="appRoleTemplate" type="x-jquery-tmpl">
    <tr id="${AppRoleCode}appRole" onclick="selectAppRole('${AppRoleCode}');" class="appRoleRec">
        <td id="appRoleCode${AppRoleCode}" class="dataGrid">${AppRoleCode}</td>
        <td id="appRoleDesc${AppRoleCode}" class="dataGrid">${ShortDesc}</td>
    </tr>
</script>

JS CODE

    function getAppRoleList() {
        var appBusinessEntityID = <%=Request.QueryString["selectedAppBusinessEntityID"].ToString() %>;
        $("#appRoleHeader").html("Application Roles - Business Entity " + appBusinessEntityID);
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "Services/AppRole.asmx/GetAppRoleList",
            dataType: "json",
            data: "{'appBusinessEntityID' : " + appBusinessEntityID + "}",
            success: function (msg) {
                getAppRoleListCallback(msg);
            },
            error: errorHandler
        });            
    }

    function getAppRoleListCallback(result) {
        var appRoleList = result.d;
        if (appRoleList.length > 0) {
            $("#appRoleTemplate").tmpl(appRoleList).appendTo("#appRoleListOutput");                       
            var appRoleTable = $("#appRoleTable").dataTable({                
                "bRetrieve": true,
                "iDisplayLength": 10,
                "bJQueryUI": true
            });
            var firstAppRoleCode = $(".appRoleRec:first").attr("id");
            firstAppRoleCode = firstAppRoleCode.replace("appRole", "");
            selectAppRole(firstAppRoleCode);
        }
    }

HTML

                                <table id="appRoleTable" class="display">
                                    <thead>
                                        <tr>
                                            <th align="left">Role Code</th>
                                            <th align="left">Description</th>
                                        </tr>
                                    </thead>
                                    <tbody id="appRoleListOutput">
                                    </tbody>
                                </table>

After executing another function to for instance, delete a record, I would expect that I could just execute the JavaScript code to call the ajax and re-render the template and reapply the dataTables plug-in to the table but it is not working properly. Row count is off.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:37:46+00:00Added an answer on May 23, 2026 at 7:37 pm

    Maybe you need to destroy the datatable, before you can re-render it. At least thats what I am doing:

    // destroy old table
    $("#appRoleTable").dataTable().fnDestroy();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building web a javascript application using jquery, knockoutjs and less (for css). Works
We're using the jQuery DataTables plug-in . The plug-in seems to be quite a
I am new to web development. I am using jquery templates and they work
I ended up using jquery templates and so far everything is working fine, but
I am using jQuery Templates successfully but I have a blur function that is
I am using JQuery Templates to render a number of tables from a JSON
I'm using jquery templates to populate a table. I'm wondering if it's possible to
I am using jquery templates on both the server-side and client-side. I'm using the
I am using Jquery templates to display incoming JSON data I would like to
i've just started using jQuery Templates as my javascript template engine. My question is,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.