javascript - How can i change the position of floatable form in extjs - Stack Overflow

I have the ExtJS form which is floatingNow i want to give % margin from top and left but its not workin

I have the ExtJS form which is floating

Now i want to give % margin from top and left but its not working.

Example is here :

var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    floating: true,
     closable : true,
    y: '10%',
    x: '10%',

});
f.show();

I have the ExtJS form which is floating

Now i want to give % margin from top and left but its not working.

Example is here :

https://fiddle.sencha./#fiddle/1dj

var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    floating: true,
     closable : true,
    y: '10%',
    x: '10%',

});
f.show();
Share Improve this question edited Nov 7, 2013 at 4:43 Hariharan 3,2634 gold badges22 silver badges31 bronze badges asked Nov 7, 2013 at 4:19 user191542user191542 2851 gold badge8 silver badges17 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

Try the below for size:

var leftPercent=10;
var rightPercent=10;
// Create a viewport, this automatically scales to the window height/width so is predictable in its size
var viewport=Ext.create('Ext.container.Viewport', {
    items:[
        f
    ],
    listeners:{
        resize:function(){
            // if the form has been added to the viewport, change its position
            f && f.setPosition(viewport.getWidth()*(rightPercent/100), viewport.getHeight()*(rightPercent/100));
        }  
    }
});


var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    autoShow:true,
    floating: true,
    // set the initial position of the form (not necessarily needed)
    x:viewport.getWidth()*(rightPercent/100),
    y:viewport.getHeight()*(rightPercent/100)    
});

It should provide you a decent basis to improve/edit. The important things are:

  1. The window is placed within a ponent/element which is known (e.g. the viewport per above)

  2. The height/width of the parent container behave as predicted during user interaction with the view

  3. Any alterations to the height width of the parent container, then lead the child container to reposition itself accordingly

You can change the position of Ext.form.Panel by using setPosition() function.

Eg:-

var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    floating: true,
     closable : true,
    y: '10%',
    x: '10%',

});
f.show();
f.setPosition(100, 200, true);

Please refer below code.

Config:

region -> Defines the region inside

padding -> Specifies the padding for this ponent

var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    floating: true,
    closable : true,
    //padding : '10 0 0 20', // example: '10 0 0 20' (top, right, bottom, left).
    region : 'center'  // possible values north, south, east, west, and center

});
f.show();

Note: padding used for smaller variation.

Second try :

var f = new Ext.form.Panel({
    width: 400,
    height: 400,
    title: 'Foo',
    floating: true,
    closable : true,
    left : 10,
    top : 10

});
f.show();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744715931a4589617.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信