diff --git a/ajax_list.js b/ajax_list.js index 5bea4f6..fe2209f 100644 --- a/ajax_list.js +++ b/ajax_list.js @@ -252,6 +252,8 @@ $=jQuery; activate=0; + num_items_default=20; + //order ASC=0, DESC=1 order=0; @@ -283,6 +285,8 @@ $=jQuery; /*$(this).append(list_tr);*/ + arr_num_items=[0, 10, 20, 50, 100]; + if(!options.hasOwnProperty("num_elements")) { options.num_elements=20; @@ -306,7 +310,6 @@ $=jQuery; } - this.fields=fields; this.options=options; @@ -371,6 +374,7 @@ $=jQuery; $(this).append(list_tr); + options.num_elements=$('#'+$(this).attr('id')+'_number_of_items').val(); //In url you can send, begin_page, num_elements for pagination. @@ -565,9 +569,32 @@ $=jQuery; console.log('Search all...') - $('
').insertBefore($(this)); + $('
').insertBefore($(this)); //console.log($(this).attr('id')); + var index=arr_num_items.indexOf(options.num_elements); + + if(index!=-1) { + + //console.log(index); + //'+$(this).attr('id')+'_number_of_items + + $('#'+$(this).attr('id')+'_number_of_items option:eq('+index+')').prop('selected', true); + + } + + $('#'+$(this).attr('id')+'_number_of_items').on('change', {table: this}, function (e) { + + begin_page=0; + + e.data.table.updateAjaxList(); + + e.preventDefault(); + + return false; + + }); + //$(form).find(".input_performance").on('keyup', function (e) { function update_list_search(e) {