roojs-all.js
[roojs1] / examples / bootstrap / TabPanel-ComboBox.js
index 21a49a5..56668fc 100644 (file)
@@ -2,7 +2,7 @@
 
 Roo.example = Roo.example || {};
 
-Roo.example.combobox = new Roo.XComponent({
+Roo.example.TabPanelCombobox = new Roo.XComponent({
     part     :  ["layout","viewpanel"],
     order    : '001-viewpanel',
     region   : '',
@@ -13,51 +13,39 @@ Roo.example.combobox = new Roo.XComponent({
     _tree : function()
     {
         
-        this.parent = {
-            el : new Roo.bootstrap.Body()
-        }
-        this.parent.el.layout = false;
-        this.parent.el.render(document.body);
         
         var _this = this;
         var MODULE = this;
-        var baseURL = '/web.eventmanager/demo.local.php';
-        
+         
         return {
             xtype: 'Body',
             xns: Roo.bootstrap,
             items : [
                  {
-                    '|xns' : 'Roo.bootstrap',
                     xtype : 'Container',
                     cls : 'content',
                     xns : Roo.bootstrap,
                     style : 'margin-top:100px',
                     items : [
                        {
-                            '|xns' : 'Roo.bootstrap',
                             xtype : 'Container',
                             cls : 'pad-wrapper',
                             xns : Roo.bootstrap,
                             items : [
                                {
-                                    '|xns' : 'Roo.bootstrap',
                                     xtype : 'Container',
                                     cls : 'container alpha',
                                     xns : Roo.bootstrap,
                                     items : [
                                        {
-                                            '|xns' : 'Roo.bootstrap',
                                             xtype : 'Container',
                                             xns : Roo.bootstrap,
                                             items : [
                                                {
-                                                    '|xns' : 'Roo.bootstrap',
                                                     xtype : 'NavSimplebar',
                                                     xns : Roo.bootstrap,
                                                     items : [
                                                        {
-                                                            '|xns' : 'Roo.bootstrap',
                                                             navId : '#top',
                                                             xtype : 'NavGroup',
                                                             xns : Roo.bootstrap,
@@ -70,33 +58,46 @@ Roo.example.combobox = new Roo.XComponent({
                                                             },
                                                             items : [
                                                                {
-                                                                    '|xns' : 'Roo.bootstrap',
-                                                                    tabId : '#one',
+                                                                    tabId : '#normal',
                                                                     xtype : 'NavItem',
                                                                     preventDefault : true,
-                                                                    html : 1,
+                                                                    html : 'Normal',
                                                                     xns : Roo.bootstrap,
                                                                     active : true,
                                                                     listeners : {
                                                                        render : function (_self)
                                                                           {
-                                                                             _this.one = this;
+                                                                             _this.normal = this;
                                                                              
                                                                           }
                                                                     }
                                                                 },
                                                                {
-                                                                    '|xns' : 'Roo.bootstrap',
-                                                                    tabId : '#two',
+                                                                    tabId : '#multiple',
                                                                     xtype : 'NavItem',
                                                                     preventDefault : true,
-                                                                    html : 2,
+                                                                    html : 'Multiple',
                                                                     xns : Roo.bootstrap,
                                                                     active : false,
                                                                     listeners : {
                                                                        render : function (_self)
                                                                           {
-                                                                             _this.two = this;
+                                                                             _this.multiple = this;
+                                                                             
+                                                                          }
+                                                                    }
+                                                                },
+                                                                {
+                                                                    tabId : '#tickable',
+                                                                    xtype : 'NavItem',
+                                                                    preventDefault : true,
+                                                                    html : 'Tickable',
+                                                                    xns : Roo.bootstrap,
+                                                                    active : false,
+                                                                    listeners : {
+                                                                       render : function (_self)
+                                                                          {
+                                                                             _this.tickable = this;
                                                                              
                                                                           }
                                                                     }
@@ -108,7 +109,6 @@ Roo.example.combobox = new Roo.XComponent({
 
                                                 },
                                                {
-                                                    '|xns' : 'Roo.bootstrap',
                                                     xtype : 'TabGroup',
                                                     style : 'margin-top:20px;',
                                                     xns : Roo.bootstrap,
@@ -116,45 +116,93 @@ Roo.example.combobox = new Roo.XComponent({
                                                     carousel : true,
                                                     items : [
                                                         {
-                                                            '|xns' : 'Roo.bootstrap',
-                                                            tabId : '#one',
+                                                            tabId : '#normal',
                                                             xtype : 'TabPanel',
                                                             xns : Roo.bootstrap,
                                                             navId : '#top',
                                                             active : true,
                                                             items : [
                                                                 {
-                                                                    '|xns' : 'Roo.bootstrap',
                                                                     level : 4,
                                                                     xtype : 'Header',
                                                                     html : 'First TabPanel With ComboBox',
                                                                     xns : Roo.bootstrap
                                                                 },
                                                                 {
-                                                                    '|xns' : 'Roo.bootstrap',
                                                                     xtype : 'Container',
                                                                     well : 'md',
                                                                     xns : Roo.bootstrap,
                                                                     items : [
                                                                         {
-                                                                            '|xns' : 'Roo.bootstrap',
                                                                             xtype : 'Row',
                                                                             xns : Roo.bootstrap,
                                                                             items : [
                                                                                 {
-                                                                                    '|xns' : 'Roo.bootstrap',
                                                                                     md : 12,
                                                                                     xtype : 'Column',
                                                                                     xns : Roo.bootstrap,
                                                                                     items : [
                                                                                         {
-                                                                                            '|xns' : 'Roo.bootstrap',
-                                                                                            labelAlign : 'top',
-                                                                                            fieldLabel : 'Family Name',
-                                                                                            xtype : 'Input',
-                                                                                            allowBlank : true,
-                                                                                            xns : Roo.bootstrap,
-                                                                                            name : 'lastname'
+                                                                                            xtype: 'ComboBox',
+                                                                                            xns: Roo.bootstrap,
+                                                                                            placeholder : 'Select a country',
+                                                                                            displayField : 'title',
+                                                                                            hiddenName : 'country_id',
+                                                                                            md : '12',
+                                                                                            size : 'sm',
+                                                                                            name : 'country_id_name',
+                                                                                            triggerAction : 'all',
+                                                                                            minChars : '1',
+                                                                                            tpl : '<li class="roo-select2-result"><b>{title}</b></div>',
+                                                                                            style : 'margin-top:20px;',
+                                                                                            listeners : {
+                                                                                                render : function (_self) {
+                                                                                                    _this.normalSel = _self;
+                                                                                                }
+                                                                                            },
+                                                                                            forceSelection : true,
+                                                                                            valueField : 'id',
+                                                                                            queryParam : 'query[name]',
+                                                                                            editable : true,
+                                                                                            alwaysQuery : true,
+                                                                                            allowBlank : false,
+                                                                                            fieldLabel : 'Country Normal',
+                                                                                            store : {
+                                                                                                xtype: 'Store',
+                                                                                                xns: Roo.data,
+                                                                                                listeners : {
+                                                                                                    beforeload : function (_self, o) {
+                                                                                                        o.params = o.params || {};
+
+                                                                                                    }
+                                                                                                },
+                                                                                                remoteSort : true,
+                                                                                                sortInfo : { direction : 'ASC', field: 'title' },
+                                                                                                proxy : {
+                                                                                                    xtype: 'HttpProxy',
+                                                                                                    xns: Roo.data,
+                                                                                                    url : '../bootstrap/data.country.js',
+                                                                                                    method : 'GET'
+                                                                                                },
+                                                                                                reader : {
+                                                                                                    xtype: 'JsonReader',
+                                                                                                    xns: Roo.data,
+                                                                                                    fields : [
+                                                                                                        {
+                                                                                                            'name': 'id',
+                                                                                                            'type': 'int'
+                                                                                                        },
+                                                                                                        {
+                                                                                                            'name': 'code',
+                                                                                                            'type': 'string'
+                                                                                                        },
+                                                                                                        {
+                                                                                                            'name': 'title',
+                                                                                                            'type': 'string'
+                                                                                                        }
+                                                                                                    ]
+                                                                                                }
+                                                                                            }
                                                                                         }
                                                                                     ]
 
@@ -169,45 +217,102 @@ Roo.example.combobox = new Roo.XComponent({
 
                                                         },
                                                         {
-                                                            '|xns' : 'Roo.bootstrap',
-                                                            tabId : '#two',
+                                                            tabId : '#multiple',
                                                             xtype : 'TabPanel',
                                                             xns : Roo.bootstrap,
                                                             navId : '#top',
                                                             active : false,
+                                                            listeners : {
+                                                                   changed : function (_self, state)
+                                                                   {
+                                                                       if(state){
+                                                                            _this.multipleSel.list.setWidth(Math.max(_this.multipleSel.inputEl().getWidth(), _this.multipleSel.minListWidth));
+                                                                        }
+                                                                   }
+                                                            },
                                                             items : [
                                                                 {
-                                                                    '|xns' : 'Roo.bootstrap',
                                                                     level : 4,
                                                                     xtype : 'Header',
-                                                                    html : 'Second TabPanel With ComboBox',
+                                                                    html : 'First TabPanel With ComboBox',
                                                                     xns : Roo.bootstrap
                                                                 },
                                                                 {
-                                                                    '|xns' : 'Roo.bootstrap',
                                                                     xtype : 'Container',
                                                                     well : 'md',
                                                                     xns : Roo.bootstrap,
                                                                     items : [
                                                                         {
-                                                                            '|xns' : 'Roo.bootstrap',
                                                                             xtype : 'Row',
                                                                             xns : Roo.bootstrap,
                                                                             items : [
                                                                                 {
-                                                                                    '|xns' : 'Roo.bootstrap',
                                                                                     md : 12,
                                                                                     xtype : 'Column',
                                                                                     xns : Roo.bootstrap,
                                                                                     items : [
                                                                                         {
-                                                                                            '|xns' : 'Roo.bootstrap',
-                                                                                            labelAlign : 'top',
-                                                                                            fieldLabel : 'Family Name',
-                                                                                            xtype : 'Input',
-                                                                                            allowBlank : true,
-                                                                                            xns : Roo.bootstrap,
-                                                                                            name : 'lastname'
+                                                                                            xtype: 'ComboBox',
+                                                                                            xns: Roo.bootstrap,
+                                                                                            placeholder : 'Select a country',
+                                                                                            displayField : 'title',
+                                                                                            hiddenName : 'country_id',
+                                                                                            md : '12',
+                                                                                            size : 'sm',
+                                                                                            name : 'country_id_name',
+                                                                                            triggerAction : 'all',
+                                                                                            minChars : '1',
+                                                                                            tpl : '<li class="roo-select2-result"><b>{title}</b></div>',
+                                                                                            style : 'margin-top:20px;',
+                                                                                            multiple: true,
+                                                                                            listeners : {
+                                                                                                render : function (_self) {
+                                                                                                    _this.multipleSel = _self;
+                                                                                                }
+                                                                                            },
+                                                                                            forceSelection : true,
+                                                                                            valueField : 'id',
+                                                                                            queryParam : 'query[name]',
+                                                                                            editable : true,
+                                                                                            alwaysQuery : true,
+                                                                                            allowBlank : false,
+                                                                                            fieldLabel : 'Country Multiple',
+                                                                                            store : {
+                                                                                                xtype: 'Store',
+                                                                                                xns: Roo.data,
+                                                                                                listeners : {
+                                                                                                    beforeload : function (_self, o) {
+                                                                                                        o.params = o.params || {};
+
+                                                                                                    }
+                                                                                                },
+                                                                                                remoteSort : false,
+                                                                                                sortInfo : { direction : 'ASC', field: 'title' },
+                                                                                                proxy : {
+                                                                                                    xtype: 'HttpProxy',
+                                                                                                    xns: Roo.data,
+                                                                                                    url : '../bootstrap/data.country.js',
+                                                                                                    method : 'GET'
+                                                                                                },
+                                                                                                reader : {
+                                                                                                    xtype: 'JsonReader',
+                                                                                                    xns: Roo.data,
+                                                                                                    fields : [
+                                                                                                        {
+                                                                                                            'name': 'id',
+                                                                                                            'type': 'int'
+                                                                                                        },
+                                                                                                        {
+                                                                                                            'name': 'code',
+                                                                                                            'type': 'string'
+                                                                                                        },
+                                                                                                        {
+                                                                                                            'name': 'title',
+                                                                                                            'type': 'string'
+                                                                                                        }
+                                                                                                    ]
+                                                                                                }
+                                                                                            }
                                                                                         }
                                                                                     ]
 
@@ -220,6 +325,109 @@ Roo.example.combobox = new Roo.XComponent({
                                                                 }
                                                             ]
 
+                                                        },
+                                                        {
+                                                            tabId : '#tickable',
+                                                            xtype : 'TabPanel',
+                                                            xns : Roo.bootstrap,
+                                                            navId : '#top',
+                                                            active : false,
+                                                            listeners : {
+                                                                   changed : function (_self, state)
+                                                                   {
+                                                                       if(state){
+                                                                            _this.tickableSel.list.setWidth(Math.max(_this.tickableSel.inputEl().getWidth(), _this.tickableSel.minListWidth));
+                                                                        }
+                                                                   }
+                                                            },
+                                                            items : [
+                                                                {
+                                                                    level : 4,
+                                                                    xtype : 'Header',
+                                                                    html : 'Second TabPanel With ComboBox',
+                                                                    xns : Roo.bootstrap
+                                                                },
+                                                                {
+                                                                    xtype : 'Container',
+                                                                    well : 'md',
+                                                                    xns : Roo.bootstrap,
+                                                                    items : [
+                                                                        {
+                                                                            xtype : 'Row',
+                                                                            xns : Roo.bootstrap,
+                                                                            items : [
+                                                                                {
+                                                                                    xtype: 'ComboBox',
+                                                                                    xns: Roo.bootstrap,
+                                                                                    placeholder : 'Select a country',
+                                                                                    displayField : 'title',
+                                                                                    hiddenName : 'country_id',
+                                                                                    md : '12',
+                                                                                    size : 'sm',
+                                                                                    name : 'country_id_name',
+                                                                                    triggerAction : 'all',
+                                                                                    minChars : '1',
+                                                                //                    tpl : '<li class="roo-select2-result"><b>{name}</b></div>',
+                                                                                    style : 'margin-top:20px;',
+                                                                                    multiple: true,
+                                                                                    tickable: true,
+                                                                                    listeners : {
+                                                                                        render : function (_self) {
+                                                                                            _this.tickableSel = _self;
+                                                                                        }
+                                                                                    },
+                                                                                    forceSelection : true,
+                                                                                    valueField : 'id',
+                                                                                    queryParam : 'query[name]',
+                                                                                    editable : true,
+                                                                                    alwaysQuery : true,
+                                                                                    allowBlank : false,
+                                                                                    fieldLabel : 'Country With Tickable',
+                                                                                    store : {
+                                                                                        xtype: 'Store',
+                                                                                        xns: Roo.data,
+                                                                                        listeners : {
+                                                                                            beforeload : function (_self, o) {
+                                                                                                o.params = o.params || {};
+
+                                                                                            }
+                                                                                        },
+                                                                                        remoteSort : false,
+                                                                                        sortInfo : { direction : 'ASC', field: 'title' },
+                                                                                        proxy : {
+                                                                                            xtype: 'HttpProxy',
+                                                                                            xns: Roo.data,
+                                                                                            url : '../bootstrap/data.country.js',
+                                                                                            method : 'GET'
+                                                                                        },
+                                                                                        reader : {
+                                                                                            xtype: 'JsonReader',
+                                                                                            xns: Roo.data,
+                                                                                            fields : [
+                                                                                                {
+                                                                                                    'name': 'id',
+                                                                                                    'type': 'int'
+                                                                                                },
+                                                                                                {
+                                                                                                    'name': 'code',
+                                                                                                    'type': 'string'
+                                                                                                },
+                                                                                                {
+                                                                                                    'name': 'title',
+                                                                                                    'type': 'string'
+                                                                                                }
+                                                                                            ]
+                                                                                        }
+                                                                                    }
+                                                                                }
+                                                                            ]
+
+                                                                        }
+                                                                    ]
+
+                                                                }
+                                                            ]
+
                                                         }
                                                     ]