I'd like to get the current selected data options like columns, rows,measures and filters on the client side. when I interigate the datasourceoptions the values are always null.
the code I've tried is below.
Also I'm using a remotedatasource, and I was wondering if there was an event or a way to grab the mdx that is being sent to the olap server.
thanks for the info..
the code I've tried for retrieving the options are below:
var dataSelector = $("#pivotView").igPivotView("dataSelector");
var ds = $("#pivotView").igPivotView("option", "dataSourceOptions");
alert(ds);
alert(ds.xmlaOptions.cube);
Hello Rob,
In order to get the columns, rows, measures or filters on the client you can use on of these options:
var measures = $("#pivotView").igPivotView("option", "dataSource").dataSource().measures();
var filters = $("#pivotView").igPivotView("option", "dataSource").dataSource().filters();
var rows = $("#pivotView").igPivotView("option", "dataSource").dataSource().rowAxis();
var columns = $("#pivotView").igPivotView("option", "dataSource").dataSource().columnAxis();
Each one of those will return the corresponding collection of items. In order to get their count you can use:
var measuresLength = measures.inner().length;
var filtersLength = filters.inner().length;
var rowsLength = rows.inner().length;
var columnsLength = columns.inner().length;
There is another way of directly accessing the items:
var firstMeasure = measures.item(0);
var secondMeasure = measures.item(1);
Where "secondMeasure" will be undefined if there is only one measure added to the pivot grid.
About your second question: there is no build-in way and no event to get the MDX that is being sent.
If there are any other questions that I might answer, please don't hesitate to ask.
Thanks,
Martin Stoev
thanks, how do I get the string values out of them. they only alert() object .
thanks again
What do you mean by string values? If you need their names you can use, for example columns:
var name = columns.item(0).caption();
Or if you need the hierarchy's unique name:
var uniqueName = columns.uniqueName();
There are also methods like: .name(), .hierarchyDisplayFolder(), .defaultMember(), etc. You can use each one of those, depending what you need.
The easiest way to do this is to bind to the "filterDropDownOk" event and get the filters from there. You just need to find the igPivotGrid widget in the igPivotView and bind to that event. Here is an example:
$("#pivotView").find('.ui-igpivotgrid').bind("igpivotgridfilterdropdownok", function(evt, ui) { var selectedMembers = ui.filterMembers; });
Then, the "selectedMembers" variable will have an array of all the filters applied. Hope this helps.
thanks that .uniqueName is what I was looking for. I didn't see anything in the documentation about the attributes on these objects.
Do the filters have different properties, like the selected values for the filters?
thx again this is very helpful..