ExtJs 4 Border Layout: Change Margins After Render

Posted By Vitaliy | March 19, 2013 | ExtJS 4.1.1
0 3870
​There is a private property margin$ which we can change and update layout.

Js Code

{
    text: 'Increment Margin',
    handler: function () {
        var root = this.up('#root'),
            west = root.down('#west'),
            center = root.down('#center'),
            wm = west.margin$,
            cm = center.margin$;

        if (wm.top <= 10) wm.top++;
        if (wm.right <= 10) wm.right++;
        if (wm.bottom <= 10) wm.bottom++;
        if (wm.left <= 10) wm.left++;

        if (cm.top <= 10) cm.top++;
        if (cm.right <= 10) cm.right++;
        if (cm.bottom <= 10) cm.bottom++;
        if (cm.left <= 10) cm.left++;

        root.doLayout();
    }
}
            

ExtJs Template: Using Template Member Functions

Posted By Vitaliy | March 11, 2013 | ExtJS 4.1.1
0 3192
​One or more member functions can be specified in a configuration object passed into the XTemplate constructor for more complex processing.

Js Code

tpl: ['<tpl for=".">',
        '<ul class="details">',
            '<li><b>Name:</b> {Name}</li>',
            '<li><b>Email:</b> {Email}</li>',
            '<tpl if="this.isDisabled(values)">',
                '<li class="warning"><b>Warning:</b> user is disabled</li>',
            '<tpl else>',
                '<li class="comment"><b>Comment:</b> active user</li>',
            '</tpl>',
        '</ul>',
      '</tpl>',
      {
          isDisabled: function (r) {
              return r.Disabled === true;
          }
      }],

            

ExtJs Template: Use For and If Statements

Posted By Vitaliy | March 11, 2013 | ExtJS 4.1.1
0 3573
The tpl tag and the for operator are used to process the provided data array.
​The tpl tag and the if operator are used to provide conditional checks for deciding whether or not to render specific parts of the template.

Js Code

tpl: ['<tpl for=".">',
        '<ul class="details">',
           '<li><b>Name:</b> {Name}</li>',
           '<li><b>Email:</b> {Email}</li>',
           '<tpl if="Comment">',
               '<li><b>Comment:</b> {Comment}</li>',
           '</tpl>',
        '</ul>',
      '</tpl>'],