How to pass url parameter value into string filter input in Google visualization

后端 未结 1 745
情深已故
情深已故 2021-01-16 12:10

Hi i am stuck on pass URL parameter values into string filter input in Google visualization.i want to pass url parameter when report is ready instead of user type on it and

相关标签:
1条回答
  • 2021-01-16 13:12

    To get the query parameter use the code (or other that you prefer):

    function getQueryVariable(variable) {
           var query = window.location.search.substring(1);
           var vars = query.split("&");
           for (var i=0;i<vars.length;i++) {
                   var pair = vars[i].split("=");
                   if(pair[0] == variable){return pair[1];}
           }
           return(false);
    }
    

    https://css-tricks.com/snippets/javascript/get-url-variables/

    Add to your filter the state value.

    var id = getQueryVariable('id'));
    
    var fteFilter = new google.visualization.ControlWrapper({ 
        'controlType': 'StringFilter', 
        'containerId': 'control_fteFilter', 
    
        'options': {           
          'filterColumnLabel': 'FTE Id' ,          
          'matchType':'any',
          'ui': {     
              'labelStacking': 'vertical',
              'label': 'FTE Id :'    
            }
        },
        state: {
            value: id
        }    
      }); 
    

    Use selectedValues array to CategoryFilter.

    state: {
        selectedValues: [id]
    }
    
    0 讨论(0)
提交回复
热议问题