[pve-devel] help with ExtJS4

Dietmar Maurer dietmar at proxmox.com
Wed Jun 29 06:40:30 CEST 2011


Hi Seth,

just commited that code. You need to use something like:

		    var sm = me.getSelectionModel();
		    var rec = sm.getLastSelected();
		    if (!rec)
			return;

		    var userid = rec.data.userid;


Take a look at www/manager/ node/NetworkView.js

- Dietmar

> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Seth Lauzon
> Sent: Dienstag, 28. Juni 2011 22:57
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] help with ExtJS4
> 
> I need to get the userid from the selected record in the User List.  Can anyone
> help?
> 
> Ext.define('PVE.dc.UserView', {
>     extend: 'Ext.grid.GridPanel',
> 
>     alias: ['widget.pveUserView'],
> 
>     initComponent : function() {
> 	var me = this;
> 
>         var tbar = [
>           {
>             text: 'Add',
>             handler: function() {
>               var msg = 'This feature is not implemented yet!';
>               Ext.Msg.alert('Not Implemented', msg);
>             }
>           },
>           {
>             text: 'Modify',
>             handler: function() {
>               var msg = 'This feature is not implemented yet!';
>               Ext.Msg.alert('Not Implemented', msg);
>             }
>           },
>           {
>             text: 'Delete',
>             handler: function() {
>               var msg = 'Are you sure you want to permanently delete the user: ' +
> me.getSelectionModel.getSelection()[0];
>               Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
>               if (btn !== 'yes')
>                   return;
>               Ext.Msg.alert('Not Implemented', 'This feature is not implemented yet!');
>               });
>             }
>           },
>         ];
> 
> 	var store = new Ext.data.Store({
> 	    model: 'pve-users',
> 	    proxy: {
>                 type: 'pve',
> 		url: "/api2/json/access/users"
> 	    },
> 	    sorters: {
> 		property: 'userid',
> 		order: 'DESC'
> 	    }
> 	});
> 
> 	var render_expire = function(date) {
> 	    if (!date)
> 		return 'never';
> 
> 	    return Ext.Date.format(date, "Y-m-d");
> 	};
> 
> 	var render_full_name = function(firstname, metaData, record) {
> 
> 	    var first = firstname || '';
> 	    var last = record.data.lastname || '';
> 	    return first + " " + last;
> 	};
> 
> 	var render_username = function(userid) {
> 	    return userid.match(/^([^@]+)/)[1];
> 	};
> 
> 	var render_realm = function(userid) {
> 	    return userid.match(/@([^@]+)$/)[1];
> 	};
> 
> 	Ext.apply(me, {
> 	    store: store,
>             tbar: tbar,
> 	    columns: [
> 		{
> 		    header: 'User name',
> 		    width: 200,
> 		    sortable: true,
> 		    renderer: render_username,
> 		    dataIndex: 'userid'
> 		},
> 		{
> 		    header: 'Realm',
> 		    width: 100,
> 		    sortable: true,
> 		    renderer: render_realm,
> 		    dataIndex: 'userid'
> 		},
> 		{
> 		    header: 'Enabled',
> 		    width: 80,
> 		    sortable: true,
> 		    dataIndex: 'enabled'
> 		},
> 		{
> 		    header: 'Expire',
> 		    width: 80,
> 		    sortable: true,
> 		    renderer: render_expire,
> 		    dataIndex: 'expire'
> 		},
> 		{
> 		    header: 'Name',
> 		    width: 150,
> 		    sortable: true,
> 		    renderer: render_full_name,
> 		    dataIndex: 'firstname'
> 		},
> 		{
> 		    id: 'comment',
> 		    header: 'Comment',
> 		    sortable: false,
> 		    dataIndex: 'comment',
> 		    flex: 1
> 		}
> 	    ],
> 	    listeners: {
> 		show: function() {
> 		    store.load();
> 		}
> 	    }
> 	});
> 
> 	me.callParent();
>     }
> }, function() {
> 
>     Ext.define('pve-users', {
> 	extend: 'Ext.data.Model',
> 	fields: [
> 	    'userid', 'firstname', 'lastname' , 'email', 'comment',
> 	    { type: 'boolean', name: 'enabled' },
> 	    { type: 'date', dateFormat: 'timestamp', name: 'expire' },
> 	],
> 	idProperty: 'userid'
>     });
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





More information about the pve-devel mailing list