1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    111
    Vote Rating
    0
    Answers
    5
    sissonb is on a distinguished road

      0  

    Default Unanswered: Nested List with Disclosure only on Leaf

    Unanswered: Nested List with Disclosure only on Leaf


    Currently I am using the getItemTextTpl configuration of the Ext.NestedList to check whether the record is a leaf. If it is I modify the template to include an element with "x-list-disclosure" as the class. This works, but is messy.

    Is there a way to use onItemDisclosure and only have it create disclosure icons on leaf items?

    Thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Inspect the DOM... is there a CSS change between if a row is a leaf or not? You may be able to hide the icon via CSS.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    111
    Vote Rating
    0
    Answers
    5
    sissonb is on a distinguished road

      0  

    Default


    Not Leaf
    HTML Code:
    <div class="x-list-item">
        <div class="x-list-item-body"><span>Today</span></div>
       <div class="x-list-disclosure"></div>
    </div>
    Leaf
    HTML Code:
    <div class="x-list-item">
        <div class="x-list-item-body">
            <span class="x-list-item-leaf">
                <div class="leaf-node">
                     <span>Torrance</span>
                </div>
            </span>
        </div>
        <div class="x-list-disclosure"></div>
    </div>
    I don't think there is a selector that can find
    HTML Code:
    .x-list-disclosure
    from
    HTML Code:
    .x-list-item-leaf
    .
    Thanks for the idea. I'll play around with it some more.
    Last edited by sissonb; 15 Dec 2011 at 4:34 PM. Reason: edit html

  4. #4
    Sencha User
    Join Date
    Feb 2011
    Posts
    111
    Vote Rating
    0
    Answers
    5
    sissonb is on a distinguished road

      0  

    Default


    So what I ended up doing is adding 2 listeners to the nested list component that adds the class leafList when all the nodes are leafs and branchList when there is a node with children in the list. Then I use some CSS to hide the buttons.

    Here's the relevant JS and CSS.
    Code:
                cardswitch:function(list, newCard, oldCard, index, animated) {               var isLeaf = true;
                   newCard.store.each(function(record, index, records) {
                       if (!record.get('leaf')) {
                           isLeaf = false;
                       }
                 });
    
    
                 if (isLeaf) {
                    this.addCls('leafList');
                    this.removeCls('branchList');
                 }
                 else {
                     this.addCls('branchList');
                     this.removeCls('leafList');
                 }
            }
    Code:
            render:function(list) {
                this.addCls('branchList');
            }
    HTML Code:
    .branchList .x-list-disclosure{    display: none;}