Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

.NET SDK Master Object Column Order

Hi all,

I have a table in the master library.  It has 8 columns, and an ID of 'vgJLah'.

I have the following code, where 'app' is an IApp instance.

IMasterObject masterObject = app.GetMasterObject("vgJLah");

var masterObjectData = masterObject.GetHyperCubeData("/qHyperCubeDef", new[] { new NxPage { Height = 1000, Width = 8 } });

This gets me the data, but I notice that the columns are not in the same order as the object in sense.

So - 2 questions:

1. Why are the columns not returned in the same order, and can this be resolved with a code change?

2. Is there any way to retrieve the headings too?

Thanks,

Shane.

Tags (4)
1 Solution

Accepted Solutions
Not applicable

Re: .NET SDK Master Object Column Order

Thanks again,

I can't call VisualizationType from GetProperties()... seems like it isn't a property of 'GenericObjectProperties'.

Shane.

8 Replies
Not applicable

Re: .NET SDK Master Object Column Order

Hi,
In version 1.0 there is limited support for Master Objects. If you want to read the properties for the "mastered"  object you will have to access the linked object on the sheet and retreive it as its type (in this case Table).

ie. sheet.GetTable("myLinkedObjectID").Properties.

1. The colums are retrieved in the order of the definition (hypercubedef), the client uses a property called columOrder which indicates the presentation order.
There are severeal ways you can handle this
- get the data and then sort the retreived columns by the property columnOrder
- GetHyperCubeData with multiple pages one page per column. Set page.right and page.left property according to the property columnOrder.

2. The heading can be retrieved thru the definition (hypercubedef), i.e. table.Properties.HyperCubeDef.Dimensions.First().Def.FieldDefs.First(). note the limited support of master obejct in version 1.0.

Best Regards
Lars-Göran Book

Not applicable

Re: .NET SDK Master Object Column Order

Hi,

The table is in the master items library but not on a sheet.  I was hoping to get its data directly using the 'GetMasterObject' call.

If I define it 'manually' in code, I'm guessing I'll have to define my own hypercube - is that the easiest way?

Thanks,

Shane.

Not applicable

Re: .NET SDK Master Object Column Order

Hi again,

Some options

You could define your own object with a hypercube.

You can create a table (on a sheet) and copy the properties from the Master Object and then get the data from this table and when finished you can delete the table.

You can create a generic session object with the properties for the Master Object and get the data from the session object.

Best regards

Lars-Göran Book

Not applicable

Re: .NET SDK Master Object Column Order

Thanks again

I tried doing something like this:

IMasterObject masterObject = app.GetMasterObject("vgJLah");

var masterProps = masterObject.Properties;

ITable table2 = app.GetSheets().ToList()[0].CreateTable("XYZ123", masterProps);

var data2 = table.GetData(new[] { new NxPage { Width = 1, Height = 100, Top = 0 } });

But I can't convert MasterObjectProperties to the required type TableProperties in the 'CreateTable' call (masterProps)...

Perhaps I'm approaching it the wrong way.

Not applicable

Re: .NET SDK Master Object Column Order

In version 1.0 of the SDK the support for master objects is limited and you can not extract the Table properties from the master object properties, which you can in the next version (1.1) of the SDK.

With version 1.0 you can get the object type (masterobject.GetProperties().VisualizationType) and create a new object of that type. To get a the properties from the master object to the table the is a method on the app

LinkMasterObject(sourceid, masterobjectid). Now you should be able to get the properties by myNewObject.<prop>

Best regards

Lars-Göran Book

Not applicable

Re: .NET SDK Master Object Column Order

Thanks again,

I can't call VisualizationType from GetProperties()... seems like it isn't a property of 'GenericObjectProperties'.

Shane.

Not applicable

Re: .NET SDK Master Object Column Order

Hi,

The visualizationType is not a property of GenericObjectProperties, you will have to get from the master object or use the Get method.

var vType = myGenericObject.GetProperties().Get<string>("visualizationType");

/ / Lars-Göran Book

Not applicable

Re: .NET SDK Master Object Column Order

Thanks for all your help

Community Browser