institut-de-genomique / Ultimate-DataTable

This AngularJS directive generate a HTML table with build-in fonctionnality like save, edit, remove, pagination etc...
http://institut-de-genomique.github.io/Ultimate-DataTable/
45 stars 26 forks source link

numberRecordsPerPageList not respected for less than four items #13

Closed Jenselme closed 8 years ago

Jenselme commented 8 years ago

If I set numberRecordsPerPageList to a list of two elements, for instance:

numberRecordsPerPageList: [
    {number: 5, clazz: ''},
    {number: 10, clazz: ''},
]

I get the following proposal for size:

But if I set my numberRecordsPerPageList to an array of 4 or more element, the choice is correctly respected.

galbini commented 8 years ago

Hello,

Thanks for your report. We use JQuery to merge the default config with the custom config. In case of array property, the default property isn't fully replace but just the elements on the same position are replaced.

Today, i don't found any solution but i tries to find it !

Jenselme commented 8 years ago

I see where the problem is. Maybe override this by hand with:

var settings = $.extend(true, {}, this.configDefault, config);
if ($.isArray(config.pagination.numberRecordsPerPageList)) {
    settings.pagination.numberRecordsPerPageList = config.pagination.numberRecordsPerPageList;
}
this.config = angular.copy(settings);

What do you think?

galbini commented 8 years ago

Your solution works but I am not sure that's the best solution. Before implement your solution, I try to search another way to resolve this problem.

Thanks for your feeback.

galbini commented 8 years ago

I resolve the problem. Can you try please ?

Jenselme commented 8 years ago

It works, thanks!