[CLOSED] [1.0] pagingtoolbar.add adds to the right of the display message instead of the left

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [1.0] pagingtoolbar.add adds to the right of the display message instead of the left

    After paging toolbar is rendered, I want to add a new text item to it. In v0.82, pagingtoolbar.add() will add the new component left aligned, after the paging stuff. Now it adds it right aligned after the Display message. Is there a way to force it to not add it to the right?

    This was reported in Sencha long time ago but got no reponse:
    http://www.sencha.com/forum/showthre...-PagingToolbar
    Last edited by geoffrey.mcgill; Jul 21, 2010 at 11:08 PM.
  2. #2
    Hi,

    I haven't tested this, but could you use .insert(0, item) instead of .add(item)?
    Geoffrey McGill
    Founder
  3. #3
    I can but it adds it before the paging stuff. I need it to be after the pager and before the display message. Or is there an easy way to tell when the pager ends so I can get the index to insert into?

    In 0.82 - add
    < < page 1 of 1 > > | newitem displaying 1-5 of 5

    In v1.0 - add
    < < page 1 of 1 > > | displaying 1-5 of 5 newitem

    In v1.0 - insert
    newitem < < page 1 of 1 > > | displaying 1-5 of 5
  4. #4
    Quote Originally Posted by jchau View Post
    I can but it adds it before the paging stuff. I need it to be after the pager and before the display message. Or is there an easy way to tell when the pager ends so I can get the index to insert into?
    Can you change the index so it adds to the desired location?
    Geoffrey McGill
    Founder
  5. #5
    Quote Originally Posted by geoffrey.mcgill View Post
    Can you change the index so it adds to the desired location?
    Is there an easy way to tell when the pager ends so I can get the index to insert into?

    Right now, I can hardcode index = 11 but it sure feels hacky to me
  6. #6
    Quote Originally Posted by jchau View Post
    Right now, I can hardcode index = 11 but it sure feels hacky to me
    Why? Unless the count of items in the Pager/Toolbar is changing, this is a perfect solution.
    Geoffrey McGill
    Founder
  7. #7
    Quote Originally Posted by geoffrey.mcgill View Post
    Why? Unless the count of items in the Pager/Toolbar is changing, this is a perfect solution.
    Because ExtJS can at any time change the pager configuration. Maybe move the refresh button next to the Display message or remove one of the separators. If we then upgrade, we would easily miss this change, and it can potentially break our code. Or if I am fired and someone new is looking at the code, they wont know why the index is hardcoded at 11 (of course i will comment the reason now but what if i didn't...). Hardcoding an index and assuming the number/order of items in a control just feel hacky in general, especially a 3rd party control.
  8. #8
    I ended up adding a new function called addToLeft to pagingtoolbar that does the insert at index 11. Turned out there were more than one page that does this so better to not hardcode it in multiple places.

    Thanks for looking into this!
  9. #9
    Quote Originally Posted by jchau View Post
    Because ExtJS can at any time change the pager configuration. Maybe move the refresh button next to the Display message or remove one of the separators. If we then upgrade, we would easily miss this change, and it can potentially break our code. Or if I am fired and someone new is looking at the code, they wont know why the index is hardcoded at 11 (of course i will comment the reason now but what if i didn't...). Hardcoding an index and assuming the number/order of items in a control just feel hacky in general, especially a 3rd party control.
    Fair enough. Valid point.

    If you can code this in markup, the following appears to position correctly.

    Example

    <ext:PagingToolbar runat="server">
        <Items>
            <ext:Label runat="server" Text="newitem" />
        </Items>
    </ext:PagingToolbar>
    Geoffrey McGill
    Founder
  10. #10
    Hi,

    This will get your the index of the Refresh button, then just +1 to insert to the right of the Refresh.

    Example

    var tb = GridPanel1.getBottomToolbar();
    var index = tb.items.indexOf(tb.refresh);
    
    tb.insert(index + 1, item);
    Hope this helps.
    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jan 27, 2012, 11:32 AM
  2. Replies: 4
    Last Post: Nov 09, 2011, 4:58 AM
  3. Replies: 3
    Last Post: Jun 22, 2011, 7:37 PM
  4. Replies: 0
    Last Post: Mar 21, 2011, 3:55 PM
  5. Replies: 1
    Last Post: Jul 07, 2010, 8:00 AM

Posting Permissions