Fixes in new lists
This commit is contained in:
parent
b51eb6faf6
commit
39d02099a6
1 changed files with 58 additions and 6 deletions
64
ajax_list.js
64
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='<a href="#" class="change_order" data-field="'+field+'">'+$(this).find('tr:first-child').children().eq(field_pos).html()+'</a>';
|
||||
html_ele='<a href="#" class="change_order" data-field="'+field+'">'+$(this).find('tr:first-child').children().eq(field_pos).html()+'</a> <span id="flag_down_'+field+'" class="order_flag fa fa-caret-square-o-down" style="display:none;"></span><span id="flag_up_'+field+'" class="order_flag fa fa-caret-square-o-up" style="display:none;"></span>';
|
||||
|
||||
$(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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue