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

quicksearch as Seller suit a group option #72

Open
dlennin opened this issue Oct 13, 2014 · 21 comments
Open

quicksearch as Seller suit a group option #72

dlennin opened this issue Oct 13, 2014 · 21 comments

Comments

@dlennin
Copy link

dlennin commented Oct 13, 2014

In the finder with multi select optgroup, to look for certain items, the search engine not only hides the parent searches pure children someone can support me

captura3

@nitriques
Copy link

Can you:

  1. Try the lastest version here https://github.com/DeuxHuitHuit/quicksearch This repo is not maintain anymore (see Deprecation notice: Version 2.0 #67)
  2. Give us the code you are using
  3. Your DOM structure.

Thanks!

@dlennin
Copy link
Author

dlennin commented Oct 15, 2014

The script I use is:

$(document).ready(function() {
    $('#sector').multiSelect({

        selectableOptgroup: true,
        selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on'               placeholder='try \"12\"'>",
        selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='try \"4\"'>",
        afterInit: function(ms){

            var that = this,

            $selectableSearch = that.$selectableUl.prev(),
            $selectionSearch = that.$selectionUl.prev(),
            selectableSearchString = '#'+that.$container.attr('id')+'.ms-optgroup-label:not(.ms-selected), .ms-elem-selectable:not(.ms-selected)',
            selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';

            that.qs1 = $selectableSearch.quicksearch(selectableSearchString)

            .on('keydown', function(e){
              if (e.which === 40){
                that.$selectableUl.focus();
                return false;
              }
            });

            that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
            .on('keydown', function(e){
              if (e.which == 40){
                that.$selectionUl.focus();
                return false;
              }
            });
        },afterSelect: function(){
          this.qs1.cache();
          this.qs2.cache();
        },
        afterDeselect: function(){
          this.qs1.cache();
          this.qs2.cache();

        }
    });

});

this is my html code:

<% Iterator<Sector> itsector = SWBComparator.sortByDisplayName(Sector.ClassMgr.listSectors(wsite),user.getLanguage()); while(itsector.hasNext()){ Sector sector = itsector.next(); %> <optgroup label="<%=sector.getDisplayTitle(user.getLanguage())%>"> <% Iterator<Sector> itsubsec = SWBComparator.sortByDisplayName(Sector.ClassMgr.listSectorByParent(sector),user.getLanguage());; while(itsubsec.hasNext()){ Sector subsec = itsubsec.next(); %> <option value="<%=subsec.getShortURI()%>" title="<%=subsec.getDisplayTitle(user.getLanguage())%>" selected="selected" disabled="disabled"><%=subsec.getDisplayTitle(user.getLanguage())%></option> <%}%> </optgroup> <%}%>

captura3

This is the image that is built multiselect, a search is done but I need to also look in the optgroup and there but you hide matches, currently the library is prepared to do searches the options of a select but when coupled with a multiselect optgroups and is where the search options do not work anymore, I want to see how to solve it.

I hope you can help me with my problem as me it is urgent, thank you for your support.

@nitriques
Copy link

Ok but did you tried Step 1 ?

Try the lastest version here https://github.com/DeuxHuitHuit/quicksearch This repo (https://github.com/riklomas/quicksearch) is not maintain anymore (see #67)

@nitriques
Copy link

And by reading your code, I do not think you are not using it the right way... Can you reproduce it on jsbin/jsfiddle ?

@dlennin
Copy link
Author

dlennin commented Oct 15, 2014

I'm using the component like this:

http://loudev.com/#demos

in section searchable, contains only one that I need and put options as in the image oprtgroups

@nitriques
Copy link

I think you should ask them why their demo does not work: https://github.com/lou/multi-select

I was not aware that the thing existed.

But, again, please answer this question:

Did you tried with the lastest version of the quicksearch plugin here https://github.com/DeuxHuitHuit/quicksearch ?

@dlennin
Copy link
Author

dlennin commented Oct 15, 2014

the latest version of quicksearch and am taking on my part but do not know how to adapt optgroups

@nitriques
Copy link

but do not know how to adapt optgroups

No, it should work... If you could reproduce the problem on jsbin or jsfiddle I could be able to help more...

@dlennin
Copy link
Author

dlennin commented Oct 15, 2014

ok then I'll put in jsbin or jsFiddle and I put my code, thanks for the support I will leave it

I did not take

@nitriques
Copy link

thanks for the support

You're welcome. I will be a lot easier with a jsbin/jsfiddle to play with.

@dlennin
Copy link
Author

dlennin commented Oct 16, 2014

is the component of the search engine, I just do not look in the groups option in the options just do not know if I understand ???? any idea how to solve:

captura0

@nitriques
Copy link

I can't help you with a screenshot only. Please reproduce the problem on jsbin or jsfiddle I could be able to help.

@dlennin
Copy link
Author

dlennin commented Oct 16, 2014

can you tell me if you see:
https://gist.github.com/anonymous/a355598b1bc069d0d3a1

is more or less like I'm driving alone I need a search engine and the images that had showing you earlier , make inquiries about parents and children and hide you can not find but parents and also also the children I am working with the library quicksearch adapt him but not how it currently is working but I just look for the children not if I understand well ??

@nitriques
Copy link

I do not see any 'input' element in your jsbin...

@dlennin
Copy link
Author

dlennin commented Oct 16, 2014

the input element itself generate the Flight from jQuery script in section

@nitriques
Copy link

Your jsbin has an error in it (jQuery is not even loaded on the page)

@dlennin
Copy link
Author

dlennin commented Oct 16, 2014

What happens is that it has the libraries jaquey is needed, that of /jquery.multi - select.js , / jquery.quicksearch.js

I'm just showing you my code see paragraph AS build , which not only how to solve the question I have to hide in The optgroups in my Component WHEN I Search

@nitriques
Copy link

What happens is that it has the libraries jaquey is needed, t

Yeah but if you want help from me, you need to be able to reproduce the problem on jsbin. If not, I am afraid I can't do anything else.

@nckenn
Copy link

nckenn commented Jul 31, 2017

Using this plugin https://github.com/DeuxHuitHuit/quicksearch, you can do this.

$(document).ready(function() {
$('#sector').multiSelect({

    selectableOptgroup: true,
    selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on'               placeholder='try \"12\"'>",
    selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='try \"4\"'>",
    afterInit: function(ms){

        var that = this,

        $selectableSearch = that.$selectableUl.prev(),
        $selectionSearch = that.$selectionUl.prev(),
        selectableSearchString = '#'+that.$container.attr('id')+'  .ms-elem-selectable:not(.ms-selected)',
        selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';

        that.qs1 = $selectableSearch.quicksearch(selectableSearchString,{
                   'show': function () {

                        $(this).prev(".ms-optgroup-label").show();
                        $(this).show();
                    },
                    'hide': function () {
                        $(this).prev(".ms-optgroup-label").hide();
                        $(this).hide();
                    }
        })
        .on('keydown', function(e){
          if (e.which === 40){
            that.$selectableUl.focus();
            return false;
          }
        });

        that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
        .on('keydown', function(e){
          if (e.which == 40){
            that.$selectionUl.focus();
            return false;
          }
        });
    },afterSelect: function(){
      this.qs1.cache();
      this.qs2.cache();
    },
    afterDeselect: function(){
      this.qs1.cache();
      this.qs2.cache();

    }
});

@puneetpapneja
Copy link

This is working for me.
Thanks
I have 2 more issues

  1. this can not hide for selected optgroups but in deselect list no items is there.
  2. i want to search with optgroups also.
    Can you please help ?

@jaredshito
Copy link

jaredshito commented Jul 25, 2018

hi , the last script work 4 me i see the two inputs to search in the select , but i have a problem, in my page i see a select button that says nothing selected and i dont know why is right here i add my code and a screen of the issue(sorry 4 my inglish)
html:

 <select id="estudios" class="searchable" name="estudios[]" multiple="multiple">
	<?
		foreach($tipoestudios as $tipoestudio)
		{
			echo '<optgroup label="'.$tipoestudio->nombre.'">';
			
				$catestudios = $this->m_estudios->obt_CatEstudios($tipoestudio->id);
				
				foreach($catestudios as $catestudio)
				{
					echo '<option value="'.$catestudio->id.'">'.$catestudio->nombre.'</option>';
				}
				
			echo '</optgroup>';
		}
	?>
	
</select>

javascript:
<script type="text/javascript">
$(document).ready(function() {
$('#estudios').multiSelect({

selectableOptgroup: true,
selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on'               placeholder='buscar'>",
// selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='buscar'>",
afterInit: function(ms){

    var that = this,

    $selectableSearch = that.$selectableUl.prev(),
    $selectionSearch = that.$selectionUl.prev(),
    selectableSearchString = '#'+that.$container.attr('id')+'  .ms-elem-selectable:not(.ms-selected)',
    selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';

    that.qs1 = $selectableSearch.quicksearch(selectableSearchString,{
               'show': function () {

                    $(this).prev(".ms-optgroup-label").show();
                    $(this).show();
                },
                'hide': function () {
                    $(this).prev(".ms-optgroup-label").hide();
                    $(this).hide();
                }
    })
    .on('keydown', function(e){
      if (e.which === 40){
        that.$selectableUl.focus();
        return false;
      }
    });

    that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
    .on('keydown', function(e){
      if (e.which == 40){
        that.$selectionUl.focus();
        return false;
      }
    });
},afterSelect: function(){
  this.qs1.cache();
  this.qs2.cache();
},
afterDeselect: function(){
  this.qs1.cache();
  this.qs2.cache();

}

});
});
screen:
captura de pantalla 178

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

5 participants