cancel
Showing results for 
Search instead for 
Did you mean: 
Community_Admin
Community Team Member
Community Team Member

Question

Is there a way to set the default panel of the BLOX widget to the month that is currently set in the FilterDash month? That was when a user loads the page, they don't get confused by the mixed messages of BloX vs rest of widgets?

Answer

You can use the following code to achieve this functionality:
widget.on('queryend', function(scope, args) {
 
 /*Configuration settings*/
 var dimension = '[Dim_Dates.Date (Calendar)]'
 var dateDimension = true
 var panel = 'Month'
 
 
 
 var requiredValue
 var filter = args.widget.dashboard.filters.item(dimension)
 if (filter && filter.jaql && filter.jaql.filter && filter.jaql.filter.members) {
  requiredValue =  filter.jaql.filter.members[0]
  if (dateDimension) {
   requiredValue = requiredValue.substr(0, 10)
  }
 } else {
  return
 }
 var panelIndex
 
 args.rawResult.metadata.forEach(function(item, i) {
  if (item.PanelName === panel) {
   console.log(item);
   panelIndex = i
  }
 })
 
 if (typeof(panelIndex) === 'undefined') {
  return 
 }

 var index
 var taleArray = []
 var headArray = []
 var expectedElement 
 
 args.rawResult.values.forEach(function(value, i) {
  if (dateDimension && value[panelIndex].data.substr(0, 10) === requiredValue) {
   index = i
  } else if (value[panelIndex].text === requiredValue) {
   index = i
  }
 })
 
 if (!index) {
  return 
 }
 var newOrder = []

 newOrder.push(args.rawResult.values[index])

 for (var i=index+1; i<args.rawResult.values.length; i++) {
  newOrder.push(args.rawResult.values[i])
 }

 for (var i=0; i<index; i++) {
  taleArray.push(args.rawResult.values[i])
 }

 taleArray.forEach(function(item) {
  newOrder.push(item)
 })
 if (newOrder.length === args.rawResult.values.length) {
  args.rawResult.values = newOrder
 }
})
 
Version history
Last update:
‎10-19-2021 01:53 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: