<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Checkbox in dropdown to select multiple attribute values in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1087481#M74234</link>
    <description>&lt;P&gt;Maybe checkboxes would work better than a dropdown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div class="checkboxContainer"&amp;gt;
  &amp;lt;input type="checkbox" id="online" name="online"&amp;gt;
  &amp;lt;label for="online"&amp;gt;Online&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="poweredOff" name="poweredOff"&amp;gt;
  &amp;lt;label for="poweredOff"&amp;gt;Powered Off&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="linkDown" name="linkDown"&amp;gt;
  &amp;lt;label for="linkDown"&amp;gt;Link Down&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="gemPacketLoss" name="gemPacketLoss"&amp;gt;
  &amp;lt;label for="gemPacketLoss"&amp;gt;GEM Packet Loss&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="lowOpticalPower" name="lowOpticalPower"&amp;gt;
  &amp;lt;label for="lowOpticalPower"&amp;gt;Low Optical Power&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a big list of options, you can make it scrollable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;.checkboxContainer {
  border:2px solid #ccc;
  width:200px;
  height: 100px;
  overflow-y: scroll;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Aug 2021 14:29:47 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-08-10T14:29:47Z</dc:date>
    <item>
      <title>Checkbox in dropdown to select multiple attribute values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1087419#M74231</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please suggest what is the procedure to create a dropdown checkbox to select multiple values from the table. I have created a dropdown list that shows customer status. Users can select the online status to reflect the record of online customer to the map as it is there are multiple statuses that can be select one by one.&lt;/P&gt;&lt;P&gt;Now, I want to create a checkbox with the dropdown list. User want to select multiple status at a time.&lt;/P&gt;&lt;P&gt;Please suggest or help me to find out the solution.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import React, { Component } from 'react';
import { Navbar, NavbarBrand, Nav, NavbarToggler, Collapse, NavItem,Dropdown,DropdownToggle,
    DropdownMenu,DropdownItem,UncontrolledDropdown} from 'reactstrap';
import { NavLink } from 'react-router-dom';
import { authenticationService } from '../_services/authentication';


class Header extends Component {
  constructor(props) {
    super(props);

    this.state = {
        isNavOpen: false,
        dropdownOpen:false,
        south:null,
        north:null,
        central:null,
        alarminfo:'',
        status:false,
        show:false
      };

    this.toggleNav = this.toggleNav.bind(this);
    this.toggleDrop = this.toggleDrop.bind(this);
   
  }


logout = () =&amp;gt; {
    authenticationService.logout();
}
  toggleNav() {
    this.setState({
      isNavOpen: !this.state.isNavOpen // true
    });
}
toggleDrop() {
    this.setState({
      isNavOpen: !this.state.isNavOpen // true
    });
}

 selectLayer = (e) =&amp;gt; {
     let _this = this

    if(this.props.loginRole.data.role === 'Admin'){

        let customerQuery = this.props.item.customer.data
        var query = customerQuery.createQuery();
    
        let centerCustomerQuery = this.props.centerItem.centerCustomer.data
        var centerQuery = centerCustomerQuery.createQuery();
    
        let northCustomerQuery = this.props.northItem.northCustomer.data
        var northQuery = northCustomerQuery.createQuery();

        if(e.target.value === "clear"){
            /*  this.props.view.goTo({
                  target:[67.116733,24.898892],
                  zoom:14
              }) */ 

              let clearQuery = "status = 'Active'"
              customerQuery.definitionExpression = clearQuery
              centerCustomerQuery.definitionExpression = clearQuery
              northCustomerQuery.definitionExpression = clearQuery
           
              query.where = clearQuery
              customerQuery.queryFeatures(query)
                .then(function(response){
                   
                    _this.setState({
                        show:true
                    })
                    
                    _this.props.alarmInfo(_this.state)
                });

                centerQuery.where = clearQuery
                centerCustomerQuery.queryFeatures(centerQuery)
                      .then(function(response){
                          _this.setState({
                            show:true
                          })
                          
                          _this.props.alarmInfo(_this.state)
                      });
                northQuery.where = clearQuery
                northCustomerQuery.queryFeatures(northQuery)
                    .then(function(response){
                        _this.setState({
                            show:true
                        })
                      
                        _this.props.alarmInfo(_this.state)
                    });

              query.where = clearQuery
              centerQuery.where = clearQuery
              northQuery.where = clearQuery
           
          }
          else {
              //var queryExpression = `status = '${e.target.value}'`
              var queryExpression = `alarmstate = ${e.target.value} AND status = 'Active'`

              // South
              customerQuery.definitionExpression = queryExpression
              query.where = queryExpression
              customerQuery.queryFeatures(query)
                .then(function(response){
                    if (response.features[0].attributes.alarmstate === 0){
                        _this.setState({
                            alarminfo:'Online',
                            south:response.features.length,
                            status:true,
                            show:false
                        })
                    }else if (response.features[0].attributes.alarmstate === 1){
                        _this.setState({
                            alarminfo:'Powered Off',
                            south:response.features.length,
                            status:true,
                            show:false
                        })
                    }else if (response.features[0].attributes.alarmstate === 2){
                        _this.setState({
                            alarminfo:'Link Down',
                            south:response.features.length,
                            status:true,
                            show:false
                        })
                    }else if (response.features[0].attributes.alarmstate === 3){
                        _this.setState({
                            alarminfo:'GEM Packet Loss',
                            south:response.features.length,
                            status:true,
                            show:false
                        })
                    }else if (response.features[0].attributes.alarmstate === 4){
                        _this.setState({
                            alarminfo:'Low Optical Power',
                            south:response.features.length,
                            status:true,
                            show:false
                        })
                    }else
                    _this.setState({
                        alarminfo:response.features[0].attributes.alarminfo,
                        south:response.features.length,
                        status:true,
                        show:false
                    })
                    
                    _this.props.alarmInfo(_this.state)
                });
                // Central
              centerCustomerQuery.definitionExpression = queryExpression
              centerQuery.where = queryExpression
              centerCustomerQuery.queryFeatures(centerQuery)
                    .then(function(response){
                        _this.setState({
                            central:response.features.length,
                            show:false
                        })
                        
                        _this.props.alarmInfo(_this.state)
                    });
                // North
              northCustomerQuery.definitionExpression = queryExpression
              northQuery.where = queryExpression
              northCustomerQuery.queryFeatures(northQuery)
                    .then(function(response){
                        _this.setState({
                            north:response.features.length,
                            show:false
                        })
                        
                        _this.props.alarmInfo(_this.state)
                    });
                
              query.where = queryExpression
              centerQuery.where = queryExpression
              northQuery.where = queryExpression
      
            

              
          }
    }
    else {

        let customerQuery = this.props.item.customer.data
        var query = customerQuery.createQuery();

        if(e.target.value === "clear"){
              let clearQuery = "1=1"
              customerQuery.definitionExpression = clearQuery  
              
              query.where = clearQuery
          }
          else {
              //var queryExpression = `status = '${e.target.value}'`
              var queryExpression = `alarmstate = ${e.target.value} AND status = 'Active'`
              customerQuery.definitionExpression = queryExpression
      
              query.where = queryExpression
          }
    }
    

}

  render() {
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;Navbar color="dark" dark expand="md"&amp;gt;
                    &amp;lt;NavbarToggler onClick={this.toggleNav} /&amp;gt;
                    &amp;lt;NavbarBrand style={{color:'#1f91f3'}}&amp;gt;Transworld&amp;lt;/NavbarBrand&amp;gt;
                    &amp;lt;Collapse isOpen={this.state.isNavOpen} navbar&amp;gt;

                        &amp;lt;Nav  className="ml-auto" navbar&amp;gt;
                            &amp;lt;UncontrolledDropdown nav inNavbar&amp;gt;
                                &amp;lt;DropdownToggle style={styles.dropToggle} nav caret&amp;gt;
                                    Customer Status
                                &amp;lt;/DropdownToggle&amp;gt;
                                &amp;lt;DropdownMenu onClick={(e)=&amp;gt; this.selectLayer(e)} style={{background:"#343a40"}} center&amp;gt;
                                    &amp;lt;DropdownItem value = "clear" style={styles.dropItem}&amp;gt;Clear Selection&amp;lt;/DropdownItem&amp;gt;
                                    &amp;lt;DropdownItem value='0' style={styles.dropItem}&amp;gt;Online&amp;lt;/DropdownItem&amp;gt;
                                    &amp;lt;DropdownItem value='1' style={styles.dropItem}&amp;gt;Powered Off&amp;lt;/DropdownItem&amp;gt;
                                    &amp;lt;DropdownItem value='2' style={styles.dropItem}&amp;gt;Link Down&amp;lt;/DropdownItem&amp;gt;
                                    &amp;lt;DropdownItem value='3' style={styles.dropItem}&amp;gt;GEM Packet Loss&amp;lt;/DropdownItem&amp;gt;
                                    &amp;lt;DropdownItem value='4' style={styles.dropItem}&amp;gt;Low Optical Power&amp;lt;/DropdownItem&amp;gt;
                                &amp;lt;/DropdownMenu&amp;gt;
                            &amp;lt;/UncontrolledDropdown&amp;gt;
                            &amp;lt;NavItem&amp;gt;
                                &amp;lt;NavLink className="nav-link"  to='/login' onClick={this.logout}&amp;gt;&amp;lt;span className="fa fa-sign-in fa-lg"&amp;gt;&amp;lt;/span&amp;gt; Logout&amp;lt;/NavLink&amp;gt;
                            &amp;lt;/NavItem&amp;gt;
                        &amp;lt;/Nav&amp;gt;
                    &amp;lt;/Collapse&amp;gt;
             
            &amp;lt;/Navbar&amp;gt;
        &amp;lt;/div&amp;gt;
    );
  }
}

const styles = {
    dropToggle:{
        background:"#343a40",
        color:"#1f91f3",
    },
    dropItem:{
        color:"#1f91f3",
    }
}

export default Header;
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kawish&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 10:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1087419#M74231</guid>
      <dc:creator>kawishabbas</dc:creator>
      <dc:date>2021-08-10T10:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Checkbox in dropdown to select multiple attribute values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1087481#M74234</link>
      <description>&lt;P&gt;Maybe checkboxes would work better than a dropdown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div class="checkboxContainer"&amp;gt;
  &amp;lt;input type="checkbox" id="online" name="online"&amp;gt;
  &amp;lt;label for="online"&amp;gt;Online&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="poweredOff" name="poweredOff"&amp;gt;
  &amp;lt;label for="poweredOff"&amp;gt;Powered Off&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="linkDown" name="linkDown"&amp;gt;
  &amp;lt;label for="linkDown"&amp;gt;Link Down&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="gemPacketLoss" name="gemPacketLoss"&amp;gt;
  &amp;lt;label for="gemPacketLoss"&amp;gt;GEM Packet Loss&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="lowOpticalPower" name="lowOpticalPower"&amp;gt;
  &amp;lt;label for="lowOpticalPower"&amp;gt;Low Optical Power&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a big list of options, you can make it scrollable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;.checkboxContainer {
  border:2px solid #ccc;
  width:200px;
  height: 100px;
  overflow-y: scroll;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 14:29:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1087481#M74234</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-08-10T14:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Checkbox in dropdown to select multiple attribute values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1088040#M74254</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp; for your kind reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is that when I applied the checkbox instead of the selection tag then how can I change my javascript code, especially &lt;STRONG&gt;queryExpression&amp;nbsp;&lt;/STRONG&gt;mentioned in line number &lt;STRONG&gt;105&lt;/STRONG&gt;.&amp;nbsp;&lt;BR /&gt;When the user checked more than two checkboxes, &lt;STRONG&gt;queryExpression&lt;/STRONG&gt; should be changed and display data to the map.&lt;/P&gt;&lt;P&gt;Reagrds,&lt;/P&gt;&lt;P&gt;Kawish&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 18:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1088040#M74254</guid>
      <dc:creator>kawishabbas</dc:creator>
      <dc:date>2021-08-11T18:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Checkbox in dropdown to select multiple attribute values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1088136#M74259</link>
      <description>&lt;P&gt;Use&amp;nbsp;querySelectorAll() to get the checked inputs by name attribute with&amp;nbsp;&lt;SPAN&gt;"input[name='status']:checked"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then you can loop over the elements to get the value. I updated my html so they all have the same name attribute for easy identifying.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div class="checkboxContainer"&amp;gt;
  &amp;lt;input type="checkbox" id="online" name="status"&amp;gt;
  &amp;lt;label for="online"&amp;gt;Online&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="poweredOff" name="status"&amp;gt;
  &amp;lt;label for="poweredOff"&amp;gt;Powered Off&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="linkDown" name="status"&amp;gt;
  &amp;lt;label for="linkDown"&amp;gt;Link Down&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="gemPacketLoss" name="status"&amp;gt;
  &amp;lt;label for="gemPacketLoss"&amp;gt;GEM Packet Loss&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
  &amp;lt;input type="checkbox" id="lowOpticalPower" name="status"&amp;gt;
  &amp;lt;label for="lowOpticalPower"&amp;gt;Low Optical Power&amp;lt;/label&amp;gt; &amp;lt;br /&amp;gt;
&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;const checkboxes = document.querySelectorAll("input[name='status']:checked");
let values = [];
checkboxes.forEach((checkbox) =&amp;gt; {
    values.push(checkbox.value);
});
console.log(values);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll need some kind of a submit button to know when the user has finished checking the options, which will be the event trigger for updating your queryExpression. &lt;A href="https://www.javascripttutorial.net/javascript-dom/javascript-checkbox/" target="_self"&gt;Here's the source&lt;/A&gt; for the logic I referenced.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 20:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1088136#M74259</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-08-11T20:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Checkbox in dropdown to select multiple attribute values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1089114#M74288</link>
      <description>&lt;P&gt;Yeah,&lt;/P&gt;&lt;P&gt;It is working. Thanks, a lot&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 13:25:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/checkbox-in-dropdown-to-select-multiple-attribute/m-p/1089114#M74288</guid>
      <dc:creator>kawishabbas</dc:creator>
      <dc:date>2021-08-14T13:25:59Z</dc:date>
    </item>
  </channel>
</rss>

