Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Code Project guys,

I am banging my head integrating this jquery datatables to my asp.net gridview. it looks like it is not possible. But before i surrender i just want to ask people here if this stuff is possible.

Link for Jquery Datatables

http://www.datatables.net/usage/[^]

My greatest roadblock is this
HTML
<script type="text/javascript" charset="utf-8">
       $(document).ready(function() {
           $('.myclass').dataTable();   --> i have tried the id of the gridview and also tried the client id $('#<%= GridView2.ClientID %>').dataTable(); but that doesn't solve the issue.
       });
    </script>

I have tried it work on html tables but not on asp.net controls. it works in asp.net repeater because html table is present. but not with the gridview.

any thoughts guys?

Thanks
Posted
Updated 9-Oct-11 9:11am
v4

Hello

Thanks for the answer. But grid view automatically becomes a table tag full of tr and td once rendered on a HTML page.

once rendered this jquery tag should work $('#ID of the grid.ClientID').dataTable();

do you have any thoughts for that?

thanks
 
Share this answer
 
Hi
From last couple of days, I had been thinking of the solution for the same problem. And I came up with an helper plugin idea that made gridview to work with dataTable plugin. Please visit below link
GridviewFix jQuery plugin[^]

Hope it will help you.

Thanks
Rupesh Kumar Tiwari
 
Share this answer
 
Is simple,
in the code behind put this code:

VB
Protected Sub gvReport_PreRender(sender As Object, e As System.EventArgs) Handles gvReport.PreRender
    If gvReport.Rows.Count > 0 Then
        gvReport.UseAccessibleHeader = True
        gvReport.HeaderRow.TableSection = TableRowSection.TableHeader
    End If
End Sub


And before, in the client side code put this:
JavaScript
$(document).ready(function(){
    $('.dataTable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "iDisplayLength": 25,
        "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "Todo"]]
    });
});
 
Share this answer
 
u should mixed it up using Repeater control.

e.g:
ASP.NET
<table id="datatable">
<thead>
 <table><tbody><tr><th>head1 </th> .... </tr></tbody></table>
</thead>
<tbody>
<asp:repeater id="rp1" runat="server" xmlns:asp="#unknown">
<itemtemplate>
<table><tbody><tr><td>item 1</td> ... </tr></tbody></table>
...
<table><tbody><tr><td>item n</td> ... </tr></tbody></table>
</itemtemplate>
</asp:repeater>
<table><tbody>
</tbody></table></tbody></table>

then call it like this
JavaScript
$(function(){
$('#datatable).dataTable({});
});


should be working out
 
Share this answer
 
Hi,

In my View it is not possible I guess.

reason is already you said in your post.grid has no table tag .

without table tag how it performs javascript actions in grid.

you 've to try another way for your requirement.

All the Best
 
Share this answer
 
Here is the solution.. that can help some one...
Out Put :

http://i49.tinypic.com/f9il41.jpg

Coding :
http://www.reddyinfosoft.blogspot.in/2012/12/aspnet-gridview-pagination-client-side.html[^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900