Sv.js 4.52 KB


function renderercell(value, metaData, record, row, col, store, gridView) {
	return '<div style="font-size: 14px; color:#3892d3;  text-align:center;">'+value+'</div>';	
}


function rendererstatusimg(value, metaData, record, rowIndex, colIndex, store) {
    if(value) {
    //	return '<div style="font-size: 14px; color:#3892d3;  text-align:center;">'+'Запущен'+'</div>';	
    return	'<span><img src="resources/img/button-green.png" height="18" width="18"/> </span>';
    }else {
     	return '<div style="font-size: 14px; color:#3892d3;  text-align:center;">'+'Остановлен'+'</div>';	 
    }
 }

function rendererstatustitle(value, metaData, record, rowIndex, colIndex, store) {
    if(value) {
    	return '<div style="font-size: 14px; color:#3892d3;  text-align:center;">'+'Запущен'+'</div>';	
 
         }else {
     	return '<div style="font-size: 14px; color:#3892d3;  text-align:center;">'+'Остановлен'+'</div>';	 
    }
 }



Ext.define('App.view.Sv', {
    extend : 'Ext.grid.Panel',
    xtype  : 'mvvm-SvView',
    title : 'Управление службами',
    store : 'Sv',
    		
    bbar: {
    	    items: [ 
    			          {
    			                xtype: 'button',
    			                iconCls:'load',
    			                itemId: 'LoadSvButton',
    			                text: 'Обновить',
    			                action: 'loadSv',
    			                disabled:false
    			            }
    	            ]
    	    		},		
    		 width: 500,
             height: 300,   
          	 selType: 'rowmodel',
             plugins: [new 	Ext.create('Ext.grid.plugin.RowEditing', {
                    	   		clicksToEdit: 2,
                    	   		pluginId: 'modelSvEditPlagin'
                       	})
             ],
             columns: [{ 
				            text      : '№',  
				            dataIndex : 'id', 
				            flex: 1,
				            hidden:true
             			},
             			
             			
             		      { 
				            text      : 'Статус', 
				            dataIndex : 'isrun', 
				            flex      : 1,
				            renderer:rendererstatusimg,
				           // editor: new Ext.form.TextField({
				            	allowBlank: true
				           // })
				       },
             			
             			
				       { 
				            text      : 'Процесс', 
				            dataIndex : 'process', 
				            flex      : 1,
				            renderer:renderercell,
				           // editor: new Ext.form.TextField({
				          //  	allowBlank: true
				           // })
				       },
				       
				       { 
				            text      : 'Примечание', 
				            dataIndex : 'isrun', 
				            flex      : 1,
				            renderer:rendererstatustitle,
				           // editor: new Ext.form.TextField({
				            	allowBlank: true
				           // })
				       },
				       
				       { 
				            text      : 'Автозагрузка', 
				            dataIndex : 'autostart', 
				            flex      : 1,
				            xtype: 'checkcolumn'
				       },
				       
				       
				       {
				            xtype:'actioncolumn', 
				            margin: "10 20 20 20",
				              items: [{
				                icon: 'resources/img/start.png',  
				                tooltip: 'Запустить',
				                margin: "10 20 20 20",
				                handler: function(grid, rowIndex, colIndex) {
				                    var rec = grid.getStore().getAt(rowIndex);
				                    alert("Edit " + rec.get('firstname'));
				                }
				            },{
				                icon: 'resources/img/stop.png',
				                tooltip: 'Остановить',
				                margin: "10 20 20 20",
				                handler: function(grid, rowIndex, colIndex) {
				                    var rec = grid.getStore().getAt(rowIndex);
				                    alert("Terminate " + rec.get('firstname'));
				                }                
				            },
				            {
				                icon: 'resources/img/replay.png',
				                tooltip: 'Перезапустить',
				                margin: "10 20 20 20",
				                handler: function(grid, rowIndex, colIndex) {
				                    var rec = grid.getStore().getAt(rowIndex);
				                    alert("Terminate " + rec.get('firstname'));
				                }                
				            }
				            
				            ]
				        }
				       
				      
             			
      		  ]
});