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 filter data from table.
eg :http//mypage?id=1234
var fteFilter = new google.visualization.ControlWrapper({
'controlType': 'StringFilter',
'containerId': 'control_div8',
'options': {
'filterColumnLabel': 'FTE Id' ,
'matchType':'any',
'ui': {
'labelStacking': 'vertical',
'label': 'FTE Id :'
}
}
});
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]
}