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

New search local system #11

Closed ydeshayes closed 5 years ago

ydeshayes commented 8 years ago

https://github.com/institut-de-genomique/Ultimate-DataTable/issues/3 The idea is to integrate the searchLocal process in the computeDisplayResult function.

All actions like typing search terms, hit enter etc... call the computeDisplayResult function.

In order to fix the bad line index editing when we edit a line in a filtered result, I add the allResultIndex as property in a line (displayResult.line). With this var, we can now link a displayResult line with a allResult index. That's for me a better consistant approach for futur improvement.

This new allResultIndex property is used in the saveLocal function:

this.allResult[this.displayResult[i].line.allResultIndex] = angular.copy(this.displayResult[i].data);

In the remove function:

this.config.remove.ids.success.push(this.displayResult[i].line.allResultIndex);

For now this system don't (should not) affect the group mode (filter work on not grouped line).

I've done some tests in local mode but I can't test in remote mode.

Give me your feedback in 'real life mode' !

EDIT: I've just notice a bug with the pagination I will fix it later

galbini commented 8 years ago

Hi Yann,

For your information, I started the merge of your branch in the master. The next week, i upgrade UDT in NGL and start the tests with real cases.

Best Regards, Guillaume

galbini commented 8 years ago

Hi Yann,

I begin the tests and we have a problem on pagination. The pagination toolbar is never refresh after change de number of result and when i click on a page number the page not change.

You can see the bug on demo page.

Regards, Guillaume

galbini commented 8 years ago

In your code, you convert allResult in displayResult and then you search.

 var _allResult = angular.copy(that.allResult);
                      _displayResult = _allResult.map(function(data, index){
                        var line = {
                            edit: undefined,
                            selected: undefined,
                            trClass: undefined,
                            group: false,
                            new: false,
                            allResultIndex: index
                        };
                        return {
                            data: data,
                            line: line
                        };
                      });

                      if(that.config.filter.active === true){
                        _displayResult = $filter('filter')(_displayResult, searchTerms, false);
                      }

The better way is search before convert to limit de loop on result.

ydeshayes commented 8 years ago

Hi !

I can't reproduce:

The pagination toolbar is never refresh after change de number of result and when i click on a page number the page not change.

You can see the bug on demo page.

For me https://github.com/institut-de-genomique/Ultimate-DataTable/commit/855485cb8865e4aa9b132d935ce674bfd1ec4a7a already resolve this bug, can't you check that you have all the commits and that your local branch is up to date with this PR when you test it ?

The new commit on the computeDisplayResult function do the search before convert to limit de loop on result.

thanks !

galbini commented 8 years ago

Hi Yann,

I retry and the pagination toolbar is not refresh after change the number of result by page.

See below my scenario : 1/ Load simple.html from your branch 2/ change number of result page 10 to 100

In this configuration the pagination toolbar must disappear because they are 66 results nad it's not the case. See print screen below. bug-toolbar-pagination

galbini commented 8 years ago

The remove not remove the good line after a local search because the allResultIndex is compute after filter. May be it's not possible to avoid a loop on all result to have a the good allResultIndex.

Best regards, Guillaume

ydeshayes commented 8 years ago

I've removed the commit about the optimisation to avoid the loop.

Please test if the last commit fix the pagination toolbar :)

galbini commented 8 years ago

Hi Yann,

The pagination works correctly. I need to test the loop on NGL because we have some page with 50000 results and i am afraid that slow.

Regards, Guillaume

ydeshayes commented 8 years ago

How about this PR ? :)

galbini commented 8 years ago

Hi Yann,

I try to find time to test your modifications but UDT in NGL as diverge from your version and my first step is to merge the two versions together and after i can test your upgrade. Sorry for the delay.

Best regards, Guillaume

galbini commented 5 years ago

Hi,

A new local search mode is available, see documentation. #localSearch

Enjoy Yann ;-)