1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    1
    Vote Rating
    0
    johanstenberg92 is on a distinguished road

      0  

    Default Answered: Center search field in navigationbar when using navigation view

    Answered: Center search field in navigationbar when using navigation view


    Hi!

    I'm trying to center a search field in my navigationbar when using a navigation view but I just can make it work. Can someone please show me how? Here's my code:

    Code:
    config: {        fullscreen: true,
                navigationBar: {
                    items: [
                        {
                            xtype: 'searchfield',
                               placeHolder: 'Search...',
                               listeners: {
                                keyup: function(field) {
                                
                                }
                            }
                        }
                    ]
                },
    
    
            items: [
    Everything is working but the searchbar is not centered (note I know I haven't written anything specific for centering it but when I try it doesn't center).

    Thanks in advance!

  2. The navigation bar extends titlebar which allows it's items to use the align config. However, the align config for titlebar only accepts left and right. I personally have opened a story for our internal feature request but currently you cannot center align things within a titlebar. The title is the only thing that can be centered.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The navigation bar extends titlebar which allows it's items to use the align config. However, the align config for titlebar only accepts left and right. I personally have opened a story for our internal feature request but currently you cannot center align things within a titlebar. The title is the only thing that can be centered.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  4. #3
    Sencha User
    Join Date
    Feb 2010
    Posts
    8
    Vote Rating
    0
    nello is on a distinguished road

      0  

    Default


    This took me about a day to figure out:

    this.getNavigationBar().leftBox.setCentered(true);
    Last edited by nello; 23 Mar 2013 at 3:58 PM. Reason: clarity