Eth.js 3.99 KB



Ext.define('App.view.Eth', {
    extend : 'Ext.form.field.ComboBox',
    xtype  : 'mvvm-EthView',
    store : 'Eth',
	fieldLabel: 'Eth',
	valueField:'id',
	displayField:'name',
	queryMode:'local',
	margin:'5 5 5 5',
	action:'cbxeth'	,
	listeners:{
	    scope: this,
	    
	    
	    select: function(combo, records, eOpts) {
	       // console.log(records[0].get('eth'));
	
	        Ext.Ajax.request({
          	  method: "GET",
                url: 'api/eth/byeth/'+records[0].get('name'),
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
            
                
                
                
                
                success: function(response, opts) {
               	 
               	 var result = Ext.JSON.decode(response.responseText);

          		Ext.getCmp('fromnetwork').viewModel.setData(result);
          		
       
                }, failure: function(response, opts) {
               	 // Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
                }
           });
	      
	    },

	    
	    
	    
	    
	    
	    
	    
	    
	    /*
	    afterRender: function(combo) {
		 
		    if (typeof combo.getStore().lastOptions !== "undefined") {
		   
		        combo.setValue(combo.getStore().first().get(combo.valueField));
		        
		        var value = combo.getValue();
		        var valueField = combo.valueField;
		        var record;
		        combo.getStore().each(function(r){
		            if(r.data[valueField] == value){
		                record = r;
		                return false;
		            }
		        });
	            var eth=record ? record.get(combo.displayField) : null;
	            
	           
	            	
	            	Ext.Ajax.request({
	                	  method: "GET",
	                      url: 'api/net/byeth/'+eth,
	                      headers: {
	                          'Accept': 'application/json',
	                          'Content-Type': 'application/json'
	                      },
	                  
	                      success: function(response, opts) {
	                     	 
	                     	 var result = Ext.JSON.decode(response.responseText);
	                     	 console.log(result);
	                     	 
	                     	//var detailFireSystemView = btn.up('mvvm-DetailFireSystemView');
	                		//var record = detailFireSystemView.getViewModel().getData().rec;
	                     	 
	                		Ext.getCmp('fromnetwork').viewModel.setData(result);
	                		//Ext.getCmp('fromnetwork').viewModel.bind(result);
	                		console.log(Ext.getCmp('fromnetwork').getViewModel().getData());
	                		
	                		
	                		  Ext.getCmp('ttt').setValue(result.extInfo);
	                		
	                		// me.viewModel.setData(record);
	                     	 	//if(result) {
	                     	 		//	Ext.Msg.alert('Success', 'Обновление конфигурации выполнено!');
	                     	   		//record.commit(); 
	                     	 	//}
	                     	 	//else
	                     	 		//{
	                     	 		// Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
	                     	 		//}
	                     	 
	                     	 
	                      }, failure: function(response, opts) {
	                     	 // Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
	                      }
	                 });
	            
	            
		    }
		    else {
		        
		        combo.getStore().on("load", function(store, items){
		          
		            combo.setValue(items[0].get(combo.valueField));
		            
		            var value = combo.getValue();
		            console.log(value);
		            
		        });
		    }
		}*/
	},


	
});