How to use css in extjs to modify the “browse files” button?


Tags: css,openfiledialog,extjs4.2

Problem :

I have created a menu with extjs where you click on it and can see menu items dropping down. The first item is open. This button is supposed to open a file from file-dialog. But the only way I can open the file dialog I found is to place the file dialog field in the menu by only showing the button.

Now I need help to make this button look like just regular menu item:

    var item = Ext.create('Ext.form.field.File', {
        buttonOnly: true,
        buttonText: 'Open',
        hideLabel: true,
        // maybe to add some css class here
        listeners: {
             'change': function(fb, v){
            Ext.Msg.alert('Status', item.getValue());
              }
        }
    }); 

    var mainmenu = Ext.create('Ext.menu.Menu', {
        width: 200,
        margin: '0 0 10 0',
        items: [item]
    });


Solution :

You can add the attribute buttonConfig to the Ext.form.field.File item and then use the standard attributes to a button. For example, this might work:

var item = Ext.create('Ext.form.field.File', {
    buttonOnly: true,
    buttonText: 'Open',
    hideLabel: true,
    buttonConfig: {
        style: {
          background: "#f1f1f1",
          border: 0
        }
    },
    listeners: {
         'change': function(fb, v){
        Ext.Msg.alert('Status', item.getValue());
          }
    }
}); 

Try changing putting a cls instead of a style attribute in the buttonConfig to use a CSS class instead of inline CSS.


    CSS Howto..

    how to do css changes only to links that are in side specific div without defining classes to a elements

    HTML/CSS Making a textbox with text that is grayed out, and disappears when I click to enter info, how?

    How can I make an only active on mobile devices?

    How to set the CSS class name dynamically in LessCSS?

    css - I've got a nested floating div, how do I get it to fill the entire 100%?

    How can I add the css to my project asp.net mvc? [closed]

    CSS: how to put one image and one block with two

    in one line not using float

    How to make smooth animation in css?

    How to add a border-bottom-image with css

    How to get style of a div from javascript file

    How to create flexible div items that break after the line?

    Why does a div with background-color show fixed elements below?

    How can I make a full width videojs v5 progress bar?

    How to make a image stay at the bottom but not rise up

    How can I get jQuery or Javascript to change css based on the current url?

    HTML/CSS: How do I make an input field with 2 vertically positioned buttons next to it?

    How to position a div under a link on click?

    How to control the postioning of a fieldset with css?

    How to make element instantly go back to initial position after CSS animation end?

    How to Manage Responsive Design in percentage(%)?

    how to change to color of pseudo-elements in css through jquery

    How to insert a line break before an element using CSS

    How to use numbers from a js file in the css sheet?

    How to use active and before with CSS?

    How to use CSS property position:fixed with top:50px and height:100%?

    css google font how to download and embedd in css to avoid slow load times

    How to use CSS to adjust HTML5 validation indicator

    How to do make CSS Toggle like this? [closed]

    How do I use CSS in Django?

    How do you set JavaFX TabPane CSS in code?