Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Width For Dojo Button

Note: It is related to this question.

I am trying to create a dojo button programmatically like this:

var btnOK = new dijit.form.Button({
    label: "OK",
    showLabel: true,
    style: "height: 20px; width: 50px;"
});

Now even though I specify the width, while displaying the button width is set to minimum (i.e text + margin). The reason as explained in the answer is that dojo overrides css style for button (class="dijitButtonNode"). Further (in the same answer) the width is set by overriding styles for same class.

Is it possible to do same (i.e set the width) without this css workaround ?

like image 692
Gaurav Avatar asked Jul 21 '11 04:07

Gaurav


2 Answers

Finally, I worked it out. To set the width we have to set width using dojo.style function

    dojo.create("button",{id: "btnOK",type: "button"},dojo.body());

    var btnOK = new dijit.form.Button({
                label: "OK",
                showLabel: true,
                style: "height: 20px;"
                },
               "btnOK");

    dojo.style("btnOK","width","40px");
like image 123
Gaurav Avatar answered Oct 03 '22 04:10

Gaurav


Worked for me:

    domStyle.set(btnOk.domNode, "width", "100px");
    domStyle.set(btnOk.domNode.firstChild, "display", "block");
like image 38
Mikhail Avatar answered Oct 03 '22 02:10

Mikhail