diff --git a/ajax_list.js b/ajax_list.js
index ad278e6..254eeaa 100644
--- a/ajax_list.js
+++ b/ajax_list.js
@@ -236,6 +236,12 @@ $=jQuery;
order_field='';
+ //order ASC=0, DESC=1
+
+ order=0;
+
+ order_by={};
+
if(!options.hasOwnProperty("url")) {
@@ -251,7 +257,7 @@ $=jQuery;
if(!options.hasOwnProperty("num_elements")) {
- options.num_elements=1;
+ options.num_elements=20;
}
@@ -266,6 +272,11 @@ $=jQuery;
options.order_fields=[];
}
+ else {
+
+ order_field=options.order_fields[0];
+
+ }
this.fields=fields;
@@ -285,10 +296,18 @@ $=jQuery;
if(field_pos!=-1) {
- html_ele=''+$(this).find('tr:first-child').children().eq(field_pos).html()+'';
+ html_ele=''+$(this).find('tr:first-child').children().eq(field_pos).html()+' ';
$(this).find('tr:first-child').children().eq(field_pos).html(html_ele);
+ if(field==order_field) {
+
+ $(this).find('tr:first-child').children().eq(field_pos).find('.fa-caret-square-o-down').show();
+
+ }
+
+ order_by[field]=1;
+
}
}
@@ -315,7 +334,7 @@ $=jQuery;
$.ajax({
url: options.url,
type: 'GET',
- data: {num_elements: options.num_elements, begin_page: begin_page},
+ data: {num_elements: options.num_elements, begin_page: begin_page, order_field: order_field, order: order},
table: this,
success: function (data) {
@@ -428,15 +447,48 @@ $=jQuery;
console.log('Changing order list...');
- order_field=$(this).attr('data-field');
+ field=$(this).attr('data-field');
- console.log(order_field);
+ //console.log(order_field);
begin_page=0;
+ //order=order[order_field] ? 0 : 1;
+ $('.order_flag').hide();
+
+ Object.entries(order_by).forEach(([key, value]) => {
+
+ if(key!=field) {
+
+ order_by[key]=1;
+
+ }
+
+ });
+
+ if(order_by[field]==1) {
+
+ order_by[field]=0;
+ order=order_by[field];
+ //$(this).closest('tr').find('.fa-caret-square-o-down').show();
+ $('#flag_down_'+field).show();
+
+ }
+ else {
+
+ order_by[field]=1;
+ order=order_by[field];
+ $('#flag_up_'+field).show();
+
+ //$(this).closest('tr').find('.fa-caret-square-o-up').show();
+
+ }
+
+ order_field=field;
+
//Update list getting order_field variable
- //e.data.table.updateAjaxList();
+ e.data.table.updateAjaxList();
return false;