Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
naveenbalanagu
Contributor III
Contributor III

QlikSense .Net SDK: How to retrieve data from a filter pane?

I would like to do the following actions for Filter Pane using .Net SDK.  Can anyone suggest how can I achieve the same.

  • Would like to print the list of data values in the filter pane.
  • Select one or more items in the filter pane.

Thanks

1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

One thing to know about filter panes is that they do not directly contain any data. Instead a filter pane has one or more list box children which are the ones who actually contain data. So typically, the process of getting data from a filter pane would look something like this:

var childId = filterPane.GetChildInfos().First().Id;

var listbox = app.GetObject<Listbox>(childId);

var pager = listbox.ListObjectPager;

var data = pager.GetData();

For more information on the general process of retrieving and paging data through the SDK, I would refer to this page:

Retrieving data ‒ Qlik Sense Developers

That section also contains information on how to do selections in list objects:

List object ‒ Qlik Sense Developers

View solution in original post

6 Replies
Øystein_Kolsrud
Employee
Employee

One thing to know about filter panes is that they do not directly contain any data. Instead a filter pane has one or more list box children which are the ones who actually contain data. So typically, the process of getting data from a filter pane would look something like this:

var childId = filterPane.GetChildInfos().First().Id;

var listbox = app.GetObject<Listbox>(childId);

var pager = listbox.ListObjectPager;

var data = pager.GetData();

For more information on the general process of retrieving and paging data through the SDK, I would refer to this page:

Retrieving data ‒ Qlik Sense Developers

That section also contains information on how to do selections in list objects:

List object ‒ Qlik Sense Developers

naveenbalanagu
Contributor III
Contributor III
Author

Thank you. I followed your instructions. Now, I am able to read the total number of items in the list and print some of them . But I would need to print all.

Capture.JPG

I tried couple of other methods like GetFirstPage, GetNextPage, GetPreviousPage and GetLastPage. But all of these are printing the number of  items contained in that page. I thought GetData() will retrieve all the values irrespective of which page they are in. I might be missing something. Can you assist me to get the full list of values instead of first 10 or 15.

If I remove the .First().Matrix and simply write var clientnames = pager.GetData() then it is printing the object details.

Thank you

Øystein_Kolsrud
Employee
Employee

Have a look at the "Iterate across all pages" example at this page:

Paging of data ‒ Qlik Sense Developers

Another option is (if you know the number of items is relatively small) to just set a sufficiently large page size to get all of them in one call. But be aware that a page can never contain more than 10000 cells, so if the number of entries can exceed that then you will have to page across them. If you are sure there are less than 10000 cells, then you can do like this:

var bigPage = new NxPage {Top = 0, Height = 10000, Left = 1, Width = 1}

var clientNames = pager.GetData(new[] {bigPage}).First().Matrix;

You can find further documentation of that DataPager class at the following location: DataPager Class

naveenbalanagu
Contributor III
Contributor III
Author

I tried the second method (setting the height ) but it is not printing anything.

For now what I am doing is looping through the GetNextPage() method based on the number of items/20 (as each page contains up to 20 values which is default). This is not a perfect way to achieve this. I will try IterateMethod as well.  Below is my code that will print all the values in the list using GetFirstPage and GetNextPage methods.


  1. var listbox = app.GetObject<Listbox>(childId);
  2. var pager = listbox.ListObjectPager;
  3. var numberofclients = pager.NumberOfRows;
  4. var clientnames = pager.GetFirstPage().First().Matrix;
  5. foreach (var itemclient in clientnames)
  6. {
  7.     Console.WriteLine(itemclient.ElementAt(0).Text);
  8. }
  9. Console.WriteLine("NEXT FOR LOOP");
  10. //Here I mentioned 27 in the for loop as an approximate value based on the listbox.Size.cy   which returned 555 items and each page is returning 20 items. So I am guessing that there are total 555/20 = ~27 pages. I know this is not the right way to get it but couldn't get it using NxPage properties.
  11. for (int i = 0; i<27; i++)
  12. {
  13.     var pageNumber = pager.GetNextPage().First().Matrix;
  14.     foreach (var assetnames in pageNumber)
  15.     {
  16.         Console.WriteLine(assetnames.ElementAt(0).Text);
  17.     }
  18. }

Thank you so much for your help and for your swift responses.

Øystein_Kolsrud
Employee
Employee

I just realized I had written "Left = 1" in my example above. It should be "Left = 0". Perhaps that is why you didn't get any data?

By the way, here is a method that would allow you to dump all data:

private static IEnumerable<NxCell> GetAllData(ListObjectPager pager, int pageHeight = 100)

{

    var initialPageSet = new [] {new NxPage {Left = 0, Top = 0, Height = pageHeight, Width = 1}};

    return pager.IteratePages(initialPageSet, Pager.Next).SelectMany(data => data.First().Matrix.Select(row => row.First()));

}

naveenbalanagu
Contributor III
Contributor III
Author

Excellent. Thank you so much. Changing the "Left" value to 0 worked perfectly.