An open API service indexing awesome lists of open source software.

https://github.com/minisuperfiles/msfmultiselect

MSFmultiSelect (multiselect) is a pure JavaScript user-friendly multiselect library, don't need jQuery. It's very easy to use for developers and fast.
https://github.com/minisuperfiles/msfmultiselect

array-msfmultiselect easy-to-use javascript minisuperfiles multiselect pure-javascript without-jquery

Last synced: 11 days ago
JSON representation

MSFmultiSelect (multiselect) is a pure JavaScript user-friendly multiselect library, don't need jQuery. It's very easy to use for developers and fast.

Awesome Lists containing this project

README

        

# MSFmultiSelect

MSFmultiSelect (multiselect) is a pure JavaScript user-friendly multiselect library, don't need jQuery. It's very easy to use for developers and fast.

### [Documentation (Demo)](https://minisuperfiles.blogspot.com/p/documentation.html?project=msfmultiselect) | [Try it (JSFiddle)](https://jsfiddle.net/minisuperfiles/r0L2yusd/) | [Download](https://github.com/minisuperfiles/MSFmultiSelect/archive/2.4.zip)

## Installation

Use npm to install the latest version.

```
npm i msfmultiselect
```

Import MSFmultiSelect and its stylesheet.

```javascript
import MSFmultiSelect from "msfmultiselect";
import "msfmultiselect/msfmultiselect.min.css";
```

Alternatively, you can simply embed it in your HTML file.

```html

```

## Using Example

Add references to MSFmultiSelect’s JavaScript and Stylesheet.

```html

```

Select box container element.

```html



HTML
CSS
MySql
XML
JSON
YAML
MongoDB
SQLite


```

JavaScript code

```javascript
var select = new MSFmultiSelect(document.querySelector("#multiselect"), {
selectAll: true,
searchBox: true,
onChange: function (checked, value, instance) {
console.log(checked, value, instance);
},
});
```

## Syntax (arguments)

```
new MSFmultiSelect(element)
new MSFmultiSelect(element, settings)

element = document.getElementById('multiselect')
settings = {
width: 350,
height: 40,
className: 'myclass',
onChange: function(checked, value, instance) {
console.log(checked, value, instance);
},
selectAll: true,
searchBox: true,
appendTo: '#myselect',
readOnly: true,
afterSelectAll: function(checked, values, instance) {
console.log(checked, values, instance);
},
autoHide: false
}
```

### element

Give DOM select element, this element posted in your backend.

### settings (Optional)

Give the object of settings your multiselect.



  1. appendTo : give element selector string, it uses to target place to create multiselect.


  2. width : It is control of the mulitiselect width.


  3. height : It is control of the mulitiselect height.


  4. className : if you need any custom style, give css class name, it will apply to mulitiselect.


  5. onChange : When multiselect is changed this callback function will run. In this function, there are three parameters.


    1. checked : you receive boolean data, selected item checked, or unchecked.


    2. value : You get selected item value.


    3. instance : It's instance variable of mulitiselect, you can access multiselect properties and methods




  6. selectAll : If your given value is true, then the select-all feature is will enable. It helps one click to select all options


  7. afterSelectAll : When users click the select-all feature this callback function will run. In this function, there are three parameters.


    1. checked : you receive boolean data, selected item checked, or unchecked.


    2. values : You get selected item values in array.


    3. instance : It's instance variable of mulitiselect, you can access multiselect properties and methods




  8. searchBox : If your given value is true, the search box feature is will enable. It helps to search the option values.


  9. theme : There are two themes available. They are theme1 and theme2. theme1 is a regular multi-select, theme2 multi-select have directly remove selected value option button.


  10. autoHide : If your given value is false, selectable values always displayed on the screen.


MSFmultiSelect Methods

MSFmultiSelect.setValue(sellectedValues, changeTrigger)

This method is used to add selected values, this method needs two arguments, sellectedValues argument value has select option values in an array format. If you changeTrigger argument value is true then it triggers to onChange event.


  • code : select.setValue(['4','8']); //give select option values in array



MSFmultiSelect.removeValue(removeSellectedValues, changeTrigger)

This method is used to remove selected values, this method needs two arguments, removeSellectedValues argument value has select option values in an array format. If you changeTrigger argument value is true then it triggers to onChange event.


  • code : select.removeValue(['4','8']); //give select option values in array



MSFmultiSelect.getData()

This methods use to get selected values of mulitiselect


  • code : console.log(select.getData());



MSFmultiSelect.selectAll(ctrlSwitch)

This method uses to select all option in the multiselect list or unselect all option in the list, this method needs one argument and its boolean value, if give true, select all option in multiselect list or you give false value unselect all in multiselect list.


  • code : select.selectAll(true); select.selectAll(false);



MSFmultiSelect.loadSource(options)

This method uses to load options in multiselect. This method needs one argument and its need array format.


  • formet :
    var options = [
    
    {caption:'optiontext1', value:'optionvalue1', selected:true},
    {caption:'optiontext2', value:'optionvalue2', selected:false}
    ];




MSFmultiSelect.getSource()

This method uses to get current source data, it will return the array format.


  • code : console.log(select.getSource());



MSFmultiSelect.reload()

This use to recreate the mulitselect.


  • code : select.reload();



Learn more about in [minisuperfiles.blogspot.com](https://minisuperfiles.blogspot.com)