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

Unable to add a className in buttonContainer #89

Open
rpashankar opened this issue Apr 29, 2019 · 1 comment
Open

Unable to add a className in buttonContainer #89

rpashankar opened this issue Apr 29, 2019 · 1 comment

Comments

@rpashankar
Copy link

Hi,

I am trying to get a filter icon along with button text on selecting any item from the dropdown. I am trying to change the buttonContainer className value on checking any item from the drop down and get the filter glyphicon.
buttonContainer property is not getting updated..

Please find the below code i have used..

@rpashankar
Copy link
Author

render() {
   let buttonContainer='<div class="btn-group tempClass" />'
   let buttonText = options => {
     if (options.length === 0) {
       $('#mselect option').each(function() {
         let input = $('input[value="' + $(this).val() + '"]')
         input.prop('enabled', true)
         input.parent('li').addClass('active')
       })
       if (this.props.placeHolder) {
         return this.props.placeHolder
       }
     } else if (options.length === 1) {
       buttonContainer='<div class="btn-group glyphicon glyphicon-filter" />'
       return options[0].label
     } else {
       let labels = []
       buttonContainer='<div class="btn-group glyphicon glyphicon-filter" />'
       options.each(function() {
         if ($(this).attr('label') !== undefined) {
           labels.push($(this).attr('label'))
         } else {
           labels.push($(this).html())
         }
       })
       return labels.join(', ') + ''
     }
     return ''
   }
   return (
     <div>
       <div
         className={`select-box ${this.props.extraCssClass}`}
         data-label={this.props.label}
       >
         <Multiselect
           ref={this.myRef}
           // ref="myRef"
           onChange={this.handleChange.bind(this)}
           data={this.props.items}
           disabled={!this.props.items || !this.props.items.length}
           buttonWidth="175px"
           numberDisplayed="10"
           className="Select"
           buttonText={buttonText}
           multiple
           id="mselect"
           enableFiltering={this.props.enableFiltering}
           includeSelectAllOption={this.props.includeSelectAllOption}
           onSelectAll={this.handleSelectAll.bind(this)}
           onDeselectAll={this.handleDeselectAll.bind(this)}
           buttonContainer={buttonContainer}
         />
       </div>
     </div>
   )
 }

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

1 participant