Skip to content

Instantly share code, notes, and snippets.

@pro-cosmos
pro-cosmos / gist:7410825
Created November 11, 2013 10:01
extjs extend class
Extends one class to create a subclass and optionally overrides members with the passed literal. This method also adds the function "override()" to the subclass that can be used to override members of the class.
For example, to create a subclass of Ext GridPanel:
MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
constructor: function(config) {
// Create configuration for this Grid.
var store = new Ext.data.Store({...});
var colModel = new Ext.grid.ColumnModel({...});
@pro-cosmos
pro-cosmos / gist:7230760
Created October 30, 2013 10:59
autoresize
I fixed it (for now) by adding the following to the parent panel, even though it's laggy...
listeners: {
resize: function() {
Ext.each(this.items.items, function(child){
var w = child.getWidth();
child.getHeader().setWidth(w);
@pro-cosmos
pro-cosmos / gist:7026459
Created October 17, 2013 15:00
Using the 'ref' option in ExtJS 3.x
As with so many things in ExtJS, the ‘ref’ option introduced in 3.0 is not very well documented, at least as far as I can tell. Which is unfortunate, because it’s extremely useful, and drastically reduces the need for ids. Here’s an example of how to use it:
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
Ext.QuickTips.init();
// Define a simple component
MyComponent = Ext.extend(Ext.form.FormPanel, {
@pro-cosmos
pro-cosmos / gist:7026436
Created October 17, 2013 14:58
Make ExtJS 4 disabled fields darker
I find the disabled fields in ExtJS 4 (and 3) too light, especially in Safari/Chrome. Just add this to your application’s CSS file to make them darker:
.x-item-disabled {
color: #888888 !important;
-moz-opacity: 100;
opacity: 1;
}
.x-form-item-label .x-item-disabled {
color: #888888 !important;
@pro-cosmos
pro-cosmos / gist:7026421
Created October 17, 2013 14:57
Add "setLabel" to ExtJS 4 fields...
A trivial override:
Ext.form.field.Base.override({
setLabel: function (text) {
if (this.rendered) {
Ext.get(this.labelEl.id).update(text);
}
this.fieldLabel = text;
}
});
@pro-cosmos
pro-cosmos / gist:7026107
Created October 17, 2013 14:36
Короткий метод для создания модели (extjs4)
//Давайте посмотрим, как создается новая модель.
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
]
});
@pro-cosmos
pro-cosmos / MemberComponent.js
Created August 23, 2013 10:05
extjs clicked link
items = items.concat(
{
xtype: 'component',
cls: 'fieldset-margin-right10px',
html: '<a href="">Указать/Изменить</a>',
listeners: {
render: function (cmp) {
var onCLick = function() {
Docu.modules.edi.view.docs.DocumentMemberForm.showFor(me.current, me.formParams);