Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select All #20

Open
rodnorth opened this issue Dec 30, 2019 · 6 comments
Open

Select All #20

rodnorth opened this issue Dec 30, 2019 · 6 comments

Comments

@rodnorth
Copy link

Hello

We're using this component for multiselect on a WP website - it's working perfectly.

One thing we've been asked for is a 'Select All' option. I know I can do this manually outside of the component, but I notice that you have a 'Select All' option on your development roadmap. Happy to wait for this - or have a go myself.

Do you have a plan to add this soon? If you'd like me to have a go at implementing within the component - do you have a suggestion as to where you think it should appear? I can code but I'm not the worlds best designer and would hate to mess up a really well thought out add on.

Cheers Rod

@erhanfirat
Copy link
Owner

Hi Rod,

Glad to see ComboTree is working nice in your project. Actually, I did not plan to add this feature, thinking of it is produced to handle large amounts of options.
However, it sounds useful for some cases and I will add it when I have free time.
Probably, not more than 1 weak.

Good luck...

@modeverv
Copy link
Contributor

i write a code...
maybe work...

  ComboTree.prototype.selectAll = function () {
    // clear
    for (i = 0; i < this._selectedItems.length; i++) {
      let itemElem = $(
        '#' + this.comboTreeId + 'Li' + this._selectedItems[i].id
      );
      $(itemElem).find('input').prop('checked', false);
    }
    this._selectedItems = [];
    // select all
    var selected = this._selectedItems;
    $('#' + this.comboTreeId + 'ComboTreeSourceUlmain')
      .find("input[type='checkbox']")
      .each(function (idx, elem) {
        console.log(elem);
        var $itemElem = $(elem).parent('span').first();
        console.log($itemElem);
        var item = {
          id: $itemElem.data('id'),
          title: $itemElem.text(),
        };
        $(elem).prop('checked', true);
        selected.push(item);
      });
    this.refreshInputVal();
  };

@erhanfirat
Copy link
Owner

i write a code... maybe work...

  ComboTree.prototype.selectAll = function () {
    // clear
    for (i = 0; i < this._selectedItems.length; i++) {
      let itemElem = $(
        '#' + this.comboTreeId + 'Li' + this._selectedItems[i].id
      );
      $(itemElem).find('input').prop('checked', false);
    }
    this._selectedItems = [];
    // select all
    var selected = this._selectedItems;
    $('#' + this.comboTreeId + 'ComboTreeSourceUlmain')
      .find("input[type='checkbox']")
      .each(function (idx, elem) {
        console.log(elem);
        var $itemElem = $(elem).parent('span').first();
        console.log($itemElem);
        var item = {
          id: $itemElem.data('id'),
          title: $itemElem.text(),
        };
        $(elem).prop('checked', true);
        selected.push(item);
      });
    this.refreshInputVal();
  };

Thanks,
If you test it working and create a pull request I can approve willingly!

@modeverv
Copy link
Contributor

ok.
please wait...
append PR to my weekend work..

I write code and localize to jp and using in my work..

@modeverv
Copy link
Contributor

modeverv commented Oct 1, 2022

I have made PR. please check
#52

@erhanfirat
Copy link
Owner

erhanfirat commented Oct 3, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants