Category / Section
How to handle server-side filtering with dashboard parameter in design mode embedding of dashboard?
Published:
In JavaScript embedding, you may encounter issues with filter parameters not working in design mode. This article will provide you with an alternative solution to filter data values in design mode using embed_datasource_filter query parameter.
- We have Bold BI embedded samples on different platforms which you can download from here. In the provided samples, the dashboard renders in view mode by default.
- Make the necessary changes in the downloaded sample by referring to the help documentation to render the dashboard in design mode.
- Now include the embed_datasource_filter query parameter and follow the instructions provided in the documentation to implement it in your project.
public string GetDetails([FromBody] object embedQuerString)
{
var embedClass = Newtonsoft.Json.JsonConvert.DeserializeObject<EmbedClass>(embedQuerString.ToString());
var embedQuery = embedClass.embedQuerString;
// User your user-email as embed_user_email
embedQuery += "&embed_user_email=" + EmbedProperties.UserEmail;
double timeStamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
embedQuery += "&embed_server_timestamp=" + timeStamp;
embedQuery += "&embed_datasource_filter=" + "[{&Year(OrderDate)=2022}]";
var embedDetailsUrl = "/embed/authorize?" + embedQuery + "&embed_signature=" + GetSignatureUrl(embedQuery);
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(embedClass.dashboardServerApiUrl);
client.DefaultRequestHeaders.Accept.Clear();
var result = client.GetAsync(embedClass.dashboardServerApiUrl + embedDetailsUrl).Result;
string resultContent = result.Content.ReadAsStringAsync().Result;
return resultContent;
}
}
Here, we added the embed_datasource_filter query parameter with a filter value of &Year(OrderDate)=2022. Below image demonstrates the corresponding dashboard in design mode.
By following these steps, you should be able to filter data values in design mode using embed_datasource_filter query parameter.
Additional References
How to handle server-side filtering with parameters in a dashboard