Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible to add dimensions and/or expressions for an extension object using JavaScript?
Why i can't add/remove dimensions/expressions?
With this code, (in my extension) i can do it: (only add, remove function doesn't work)
_this.Layout.SetProperty("Chart.Dimension.Add", "", false)
_this.Layout.SetProperty("Chart.Dimension.1.Field", "my_new_dimension", true);
I put "1" in dimension because i've just one dimension in my table.
This code put a new dimension at the end of my (basic) html table.
With this code, i see the new dimension
// Create a variable to hold generated html
$html += "<table border='1'>";
var $headerRow = $dataSet.HeaderRows[0];
$html += "<tr>";
for (var $i = 0; $i < $headerRow.length; $i++) {
$html += "<th>" + $headerRow[$i].text + "</th>";
}
$html += "</tr>";
// Cycle Through the data
for (var $i = 0; $i < $dataSet.Rows.length; $i++) {
// get the row
var $row = $dataSet.Rows[$i];
// Generate html
$html += "<tr>";
for (var $j = 0; $j < $row.length; $j++) {
$html += "<td>" + $row[$j].text + "</td>";
}
$html += "</tr>";
}
// Finalise the html
$html += "</table>";
Hi ,
Was googling and just came across your post
Basically i am trying to do some dynamic selection from an extension object for applying selection i need to use
_this.Data.SelectTextsInColumn(0, true, "*");
here the _this.Data object refrences the Dimension field so basically i tried you above to dynamically change the field in the javascript here is the code
function getData()
{
var lineDelimiter = '\n';
var tagDelimiter = ':';
var valueDelimiter = ';';
var currentSelectionQv =_this.Layout.Text0.text;
// alert('Value from Expression ' + currentSelectionQv);
var arrSelectionLines = currentSelectionQv.split(lineDelimiter);
if (arrSelectionLines.length > 0 && arrSelectionLines[0] != '-') {
for (i = 0; i < arrSelectionLines.length; i++) {
var line = arrSelectionLines;
var tagPos = line.indexOf(tagDelimiter);
var fieldName = line.substr(0, tagPos);
var fieldValues = line.substr(tagPos + 1, line.length - tagPos).split(valueDelimiter);
alert(fieldName); // Selected Field Name
// to add dimension:
_this.Layout.SetProperty("Chart.Dimension.Add", "", false)
_this.Layout.SetProperty("Chart.Dimension.0.Field", fieldName, true);
alert('Layout Ran !');
alert(fieldValues); //Select Field Value
}
}
else
{
//Do Nothing
}
}
I will be basically using arrSelectionLines variable to feed in my Input string containing the Field name and Field value from a Web Service . Now the above code is running in a circular loop any idea why ?
Hello, Mattia,
I know it's been a long time, but only now have I stumbled upon this, searching for the answer to your question:
"how to determine the number of dimensions and expressions?"
With a bit of googling I've found this answer: QlikView Extension determine amount of Dimensions from first data row (if multiple) · GitHub, to quote:
// get amount of Dimensions
var nDimensions = this.Data.Rows[0].filter(function(col){return !(col.color == undefined);}).length;
Apparently, dimensions columns in QV generated data get their own color each, while expressions columns' color is undefined. Definitely a weird way to get to the information as useful and simple as this... but hey.
Hope someone except for me will find this useful. Thank you, ralfbecher of GitHub.
Hey Tushar,
I know this question is quite old, but did you manage to solve this problem?
I´m currently struggeling with the same situation....
Best regards
Florian
Did you find solution to add dimension dynamically?
I am trying to add dimension using below code but it is not working
object.Layout.SetProperty("Chart.Dimension.Add", "", false);
object.Layout.SetProperty("Chart.Dimension.0.Field", "MyDimension1", true);
object.Layout.SetProperty("Chart.Dimension.Add", "", false);
object.Layout.SetProperty("Chart.Dimension.1.Field", "MyDimension2", true);