Giter Club home page Giter Club logo

Comments (9)

 avatar commented on September 2, 2024 1

@raquelleira could you please check out #335? Is it possible to change the sorting so that step (1) is disabled completely?

from ng2-table.

webcat12345 avatar webcat12345 commented on September 2, 2024 1

You can customize component as below.

ng2-table/components/table/ng-table-sorting.directive.js line:17

Then you can see these code

    NgTableSortingDirective.prototype.onToggleSort = function (event) {
        if (event) {
            event.preventDefault();
        }
        if (this.ngTableSorting && this.column && this.column.sort !== false) {
            switch (this.column.sort) {
                case 'asc':
                    this.column.sort = 'desc';
                    break;
                case 'desc':
                    this.column.sort = '';
                    break;
                default:
                    this.column.sort = 'asc';
                    break;
            }
            this.sortChanged.emit(this.column);
        }
    };

This is code for switching sorting mode.
If you change this as below then you can use only two methods.

    NgTableSortingDirective.prototype.onToggleSort = function (event) {
        if (event) {
            event.preventDefault();
        }
        if (this.ngTableSorting && this.column && this.column.sort !== false) {
            switch (this.column.sort) {
                case 'asc':
                    this.column.sort = 'desc';
                    break;
                case 'desc':
                    this.column.sort = 'asc';
                    break;
                default:
                    this.column.sort = 'asc';
                    break;
            }
            this.sortChanged.emit(this.column);
        }
    };

You can fort repository and use component as freely :)

from ng2-table.

raquelleira avatar raquelleira commented on September 2, 2024

I don't think they see this as an issue.
As far as I understood, When it's ascending and you click the column, it changes to descending. When it's descending and you click it, it returns to the default order of the list...(even if the default it's no order...). And then you click again, it changes to ascending again...
I think it's actually 3 different status: 1. No order/default order as it is in the array, 2. ascending 3. descending.
I'm not saying this is good though... I actually changed my code as you suggested, so this "No order" status doesn't exists anymore...

from ng2-table.

mksasi avatar mksasi commented on September 2, 2024

Many Thanks. Can you please push this change to the master branch?

from ng2-table.

protagonist51 avatar protagonist51 commented on September 2, 2024

@raquelleira How to disable the 3rd click in ng2-table/demo/components/table/table-demo.ts file? Plese suggest

from ng2-table.

protagonist51 avatar protagonist51 commented on September 2, 2024

@webcat12345 You are awesome!!!

from ng2-table.

protagonist51 avatar protagonist51 commented on September 2, 2024

@webcat12345 Is it possible to override this functionality in the file table-demo.ts of ng2-table/demo/components/table/?? I want to have only 2 way sorting in the implementation level and this is in module level. I mean if someone wants to implement my project, he will do an "npm install ng2-table" and he has to change the below code manually
case 'desc':
this.column.sort = 'asc';
break;
So is it possible to customize this in our own code which implements ng2-table?

Thanks

from ng2-table.

protagonist51 avatar protagonist51 commented on September 2, 2024

@webcat12345 Any solution for the above problem?

from ng2-table.

webcat12345 avatar webcat12345 commented on September 2, 2024

Currently there is no other way. But you can fork this repository and can make changes to component

from ng2-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.