locked
Semantic zoom crashes with itemFromDescription not found

    Question

  • I have a semantic zoom setup, that crashes when zooming out.

    var items = new WinJS.Binding.List(results);
              var groupedByBrand = items.createGrouped(function key(item) {
                return item.brand.charAt(0);
              }, function data(item) {
                return item;
              }, function sorter(a, b) {
                return a.toLowerCase().localeCompare(b.toLowerCase());
              });
              var listView = element.querySelector("#semanticZoomAlpha").winControl;
              listView.itemDataSource = groupedByBrand.groups.dataSource;
              listView = element.querySelector(".pickerList").winControl;
              listView.itemDataSource = items.dataSource;

    When zooming out, it crashes with "Object doesn't support property or method 'itemFromDescription'". The ui.js resorts to this function since the "key" is undefined in the zoomed out view.

    Adding 

    listView.itemDataSource.itemFromDescription = function (it) {
                return WinJS.Promise.wrap({ index: 0 });
              };
              

    to the zoomed out datasource solves the problem. What is going on here?


    • Edited by pkursawe Thursday, March 20, 2014 4:58 PM
    Thursday, March 20, 2014 4:57 PM

Answers

  • I have an example app, but the error is not reproducible there.

    My set of data is slightly different, but the logic is the same.

    edit: problem solved. Very suttle.

    The last line you can see in my code posted in my inital post must read

    listView.itemDataSource = groupedByBrand.dataSource;

    Maybe the ListView should check if the dataSource actually returns keys. undefined keys should not be allowed.

    • Edited by pkursawe Friday, March 21, 2014 3:07 AM solved
    • Marked as answer by pkursawe Friday, March 21, 2014 3:07 AM
    Friday, March 21, 2014 2:59 AM

All replies

  • Can you post your complete repro sample project to OneDrive (skydrive) so that we can understand what is actually going on?

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Friday, March 21, 2014 12:43 AM
    Moderator
  • I have an example app, but the error is not reproducible there.

    My set of data is slightly different, but the logic is the same.

    edit: problem solved. Very suttle.

    The last line you can see in my code posted in my inital post must read

    listView.itemDataSource = groupedByBrand.dataSource;

    Maybe the ListView should check if the dataSource actually returns keys. undefined keys should not be allowed.

    • Edited by pkursawe Friday, March 21, 2014 3:07 AM solved
    • Marked as answer by pkursawe Friday, March 21, 2014 3:07 AM
    Friday, March 21, 2014 2:59 AM