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

  • Home
  • SEARCH
  • 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

Using jQuery, is there a way to select all tag that reference a specific
Using jQuery, how do I delete all rows in a table except the first?
I'm implementing a web app using web2py and jQuery. I want to use the
I am using a web application framework (Symfony 1.3.6), which follows the MVC pattern.
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,
I am using jQuery templates and they seem to break as soon as I
I'm using jQuery Templates from within the jQuery UI Autocomplete plugin so that I
I'm using jQuery Templates for a bunch of a site I'm working on, and
Rebecca Murphy talks about using jQuery templates. The JSON that Rebecca uses looks like:

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.