Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
43
rated 0 times [  46] [ 3]  / answers: 1 / hits: 18244  / 11 Years ago, thu, may 30, 2013, 12:00:00

In my Asp.net app, I have a Gridview Control and bind it on code behind.

And on client side I use Jquery DataTable version 1.9.4 for better Sorting,Searching functionality, Here i got one problem Numeric value not sorting properly.



I googled and come to knw by using sType: numeric will solved, but when i use this my whole working stoped my Column is at 9 position so i set aTragets 9



Here's the JS FIDDLE



Javascript:



$(document).ready(function () {
$('#ctl00_ContentPlaceHolder1_GridView3').dataTable({
bJQueryUI: true,
sPaginationType: full_numbers
// aoColumnDefs: [{ sType: numeric, aTargets: [9] }]

});
});


enter



enter



Code nehind:
On Page_PreRender



if (GridView3.Rows.Count > 0)
{
GridView3.UseAccessibleHeader = true;
GridView3.HeaderRow.TableSection = TableRowSection.TableHeader;
}


On pageLoad :



GridView3.DataSource = sortedDT;
GridView3.DataBind();

More From » jquery

 Answers
21

This is how i solved:



Gridview with Item template:



In Item template their might be label control, so it convert into span, we need to remove that span tag ie html tag using .contents().unwrap();



Code:



$(#Gridview_ID span).contents().unwrap();
$('#Gridview_ID ').dataTable({
bJQueryUI: true,
sPaginationType: full_numbers,
aoColumns: [{ bSortable: false }, null, null, { sType: numeric }, { sType: date }, null, { bSortable: false}]
});


Gridview with Bound Field:



$('#Gridview_ID ').dataTable({
bJQueryUI: true,
sPaginationType: full_numbers,
aoColumns: [{ bSortable: false }, null, null, { sType: numeric }, { sType: date }, null, { bSortable: false}]
});

[#77921] Wednesday, May 29, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jimmieo

Total Points: 515
Total Questions: 102
Total Answers: 110

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;