I would like to do the following actions for Filter Pane using .Net SDK. Can anyone suggest how can I achieve the same.
Thanks
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:
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:
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.
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
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
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.
Thank you so much for your help and for your swift responses.
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()));
}
Excellent. Thank you so much. Changing the "Left" value to 0 worked perfectly.