locked
listView question RRS feed

  • Question

  • var dataList = new WinJS.Binding.List(testArray);
    var xxx = document.getElementById("basicListView").winControl
    xxx.itemDataSource = dataList.dataSource;

    This is the binding of the data of a listview. What I am trying to do is take the itemDataSource entry and before it is sent to the screen allow conditional logic to color a item.
    When I try this it does color the item but it also colors all other items with the same id. For example I am only trying to color the second zip in this list and leave the color of the first zip item alone.

    name
    address
    zip

    name
    address
    zip

    thanks

    Sunday, April 14, 2013 3:35 PM

Answers

  • Hi B,

    How are you trying to color it?  How are you identifying that one item as unique?

    What does the DOM Explorer tell you about this while you are debugging?  Where is the style coming from and what is it set on?

    What debugging have you done so far?

    -Jeff


    Jeff Sanders (MSFT)

    • Marked as answer by baryo Tuesday, April 16, 2013 11:09 PM
    Monday, April 15, 2013 6:30 PM
    Moderator
  • Below is the answer to my problem. Using the WinJS.Utilities.query gave me what I was looking for.
    I have included the html and the script. The result I was looking for was to change the
    color on the text objects innerText for the h6 tag. Here is a complete listing of the code that lead me to
    the correct path - http://www.renauddumont.be/post/2013/01/24/Windows-8-HTMLJS-VariableSize-List-View-and-Template-Selection

    <div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template">
        <div class="mediumItem">
            <h4 data-win-bind="innerText: title"></h4>
            <h6 data-win-bind="innerText: text"></h6>
        </div>
    <div>

    var itemTemplate = WinJS.Utilities.query("#mediumListIconTextTemplate")[0];
    var itemChange = WinJS.Utilities.query("h6")[0];
    itemChange.style.color = "blue";

    • Marked as answer by baryo Tuesday, April 16, 2013 11:09 PM
    Tuesday, April 16, 2013 11:09 PM

All replies

  • Hi B,

    How are you trying to color it?  How are you identifying that one item as unique?

    What does the DOM Explorer tell you about this while you are debugging?  Where is the style coming from and what is it set on?

    What debugging have you done so far?

    -Jeff


    Jeff Sanders (MSFT)

    • Marked as answer by baryo Tuesday, April 16, 2013 11:09 PM
    Monday, April 15, 2013 6:30 PM
    Moderator
  • Below is the answer to my problem. Using the WinJS.Utilities.query gave me what I was looking for.
    I have included the html and the script. The result I was looking for was to change the
    color on the text objects innerText for the h6 tag. Here is a complete listing of the code that lead me to
    the correct path - http://www.renauddumont.be/post/2013/01/24/Windows-8-HTMLJS-VariableSize-List-View-and-Template-Selection

    <div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template">
        <div class="mediumItem">
            <h4 data-win-bind="innerText: title"></h4>
            <h6 data-win-bind="innerText: text"></h6>
        </div>
    <div>

    var itemTemplate = WinJS.Utilities.query("#mediumListIconTextTemplate")[0];
    var itemChange = WinJS.Utilities.query("h6")[0];
    itemChange.style.color = "blue";

    • Marked as answer by baryo Tuesday, April 16, 2013 11:09 PM
    Tuesday, April 16, 2013 11:09 PM