Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am using .net sdk to integrate qlik in my application. I am showing the list of App in dropdown control. I need to show list of object with Title in particular app. For this purpose currently i am fetching list of sheet in app then list of object from sheet.
Code sample :
//Here i am fetching list of sheet in app
List<SheetObjectViewListContainer> sheetList= null;
var appIdentifier = location.AppWithId(appId, noVersionCheck: true);
using (IApp app = location.App(appIdentifier, noVersionCheck: true))
{
sheetList = app.GetSheetList().Items.ToList();
}
//here i am fetching list of object from sheet by loop
foreach (SheetObjectViewListContainer sheet in sheetList)
{
foreach (var item in sheet.Data.Cells)
{
string objectID= item.Name;
string objectType= item.Type;
}
}
}
Note: Problem is i am not able to show title of object
So how can i get title of object.
Ah, sorry... I misread your original request. To get the title of the objects (I assume you want the evaluated title, not the title definition) you will have to get the layout of the individual objects. Note that not all objects necessarily have a title, but all the standard Qlik Sense visualization do and are extensions of the base class VisualizationBase in the SDK. To get the title of all those visualizations, you can do like this:
foreach (var sheet in app.Sheets())
{
foreach (var child in sheet.GetChildInfos()
.Select(o => app.GetGenericObject(o.Id))
.OfType<IVisualizationBase>())
{
Console.WriteLine("Title: " + child.Title);
}
}
You might also want to check out this example that illustrates how to traverse an app to extract data from it:
Or this example that illustrates how to trigger the computation of the layout of all objects in an app:
Hi! The title is available in the "Meta" property of the SheetObjectViewListContainer instance, but it is not visible as part of the of that C# class. You can, however, access the information through the generic AbstractStructure.Get method like this:
foreach (var sheetItem in app.GetSheetList().Items)
{
Console.WriteLine(sheetItem.Meta.Get<string>("title");
}
For more information on AbstractStructure, please refer to this page:
Another option is to open the sheets and get the title through the properties of the sheet directly like this:
foreach (var sheet in app.GetSheets())
{
Console.WriteLine(sheet.Properties.MetaDef.Title);
}
The first approach has the advantage that you don't need to do the extra communication to open the sheet objects and asking for their properties, but if you're anyway going to open the sheets, then this second approach should be fine.
Hi,
Thanks for your reply.
It does not work in my case because i need title of object within sheet. Your code is giving title of sheet.
Ah, sorry... I misread your original request. To get the title of the objects (I assume you want the evaluated title, not the title definition) you will have to get the layout of the individual objects. Note that not all objects necessarily have a title, but all the standard Qlik Sense visualization do and are extensions of the base class VisualizationBase in the SDK. To get the title of all those visualizations, you can do like this:
foreach (var sheet in app.Sheets())
{
foreach (var child in sheet.GetChildInfos()
.Select(o => app.GetGenericObject(o.Id))
.OfType<IVisualizationBase>())
{
Console.WriteLine("Title: " + child.Title);
}
}
You might also want to check out this example that illustrates how to traverse an app to extract data from it:
Or this example that illustrates how to trigger the computation of the layout of all objects in an app:
Thanks for help
Hello
Do you know how to extract info from the objects which are inside a container?
Regards
That depends on what type of object you want information for. Is it a master visualization, or a sheet, or something else? And what kind of information are you looking for. Is it the title?
Anyway, I suggest you create a new thread on this here in Community so that it doesn't get mixed up with this old thread.
Hello
I started this thread. All the details are there. Help will be appreciated:
Regards
Ozcan