Sorting Input elements
Sorting Input elements
Hello,
I created a datatables table with input textbox elements, that allows the users to insert values.
I have written a small sort plugin to sort the values.
When the sort event is fired my sort plugin receives e.g. for parameter a followign value:
I access it with the .val() function:
[code]
jQuery.fn.dataTableExt.oSort['textbox-asc'] = function (a, b) {
var x = $(a).val();
var y = $(b).val();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['textbox-desc'] = function (a, b) {
var x = $(a).val();
var y = $(b).val();
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
Here I register the datatable:
[code]
//<![CDATA[
$(function () { $('#gvData71').dataTable({'bJQueryUI': true, 'aaSorting': [ ], 'bProcessing': true, 'sPaginationType': 'full_numbers', 'oLanguage': {'sLengthMenu': 'Display '+ '10'+ '20'+ '30'+ '50'+ '100'+ 'All'+ ' records'},'aoColumns': [{ 'sSortDataType': 'dom-text', 'sType': 'textbox' } ,{ 'sSortDataType': 'dom-text', 'sType': 'de_date' } ,null,null,null,null,null],'bPaginate': false});});//]]>
[/code]
After loading the sorting works fine, but when the user starts to change values and click the sorting header again the table isn't sorted by the new values. I checked the original html after user input and the value attribute is set to the new value, but my plugin still receives the old html attribute.
Do anybody know why I receive the old value in my jQuery plugin?
I created a datatables table with input textbox elements, that allows the users to insert values.
I have written a small sort plugin to sort the values.
When the sort event is fired my sort plugin receives e.g. for parameter a followign value:
I access it with the .val() function:
[code]
jQuery.fn.dataTableExt.oSort['textbox-asc'] = function (a, b) {
var x = $(a).val();
var y = $(b).val();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['textbox-desc'] = function (a, b) {
var x = $(a).val();
var y = $(b).val();
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
Here I register the datatable:
[code]
//<![CDATA[
$(function () { $('#gvData71').dataTable({'bJQueryUI': true, 'aaSorting': [ ], 'bProcessing': true, 'sPaginationType': 'full_numbers', 'oLanguage': {'sLengthMenu': 'Display '+ '10'+ '20'+ '30'+ '50'+ '100'+ 'All'+ ' records'},'aoColumns': [{ 'sSortDataType': 'dom-text', 'sType': 'textbox' } ,{ 'sSortDataType': 'dom-text', 'sType': 'de_date' } ,null,null,null,null,null],'bPaginate': false});});//]]>
[/code]
After loading the sorting works fine, but when the user starts to change values and click the sorting header again the table isn't sorted by the new values. I checked the original html after user input and the value attribute is set to the new value, but my plugin still receives the old html attribute.
Do anybody know why I receive the old value in my jQuery plugin?
This discussion has been closed.