Show Array Data in Form Grid

Questions and answers for designing and implementing forms in Servoy

Show Array Data in Form Grid

Postby kwpsd » Thu Dec 14, 2017 6:32 am

Servoy 8.2.1
Smart Client

I need assistance/guidance...nothing I do seems to work. Also, I am open (actually, prefer) to use the In-Memory Datasources new to 8.2.1, if possible.

What is the best way to show the array results aClients in a form grid in Smart Client? We want to expose certain client manager data to admins (not regular users)...view only mode.

Code: Select all
var aClients = plugins.clientmanager.getConnectedClients()


Thank you.
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 583
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: Show Array Data in Form Grid

Postby kwpsd » Sat Dec 16, 2017 11:59 pm

Never mind...I figured it out. Sharing my code (below) for others wanting to do the same:

Code: Select all
    // Returns an array of JSClientInformation elements describing the clients connected to the server.
   
    /** @type {JSClientInformation} */

    var aClients = plugins.clientmanager.getConnectedClients()
   

    // Create an array of column names identical to those of the in-memory table.
   
    var aNamesColumns = []
    aNamesColumns.push( 'client_id' )
    aNamesColumns.push( 'client_type' )
    aNamesColumns.push( 'client_ip_address' )
    aNamesColumns.push( 'client_identifier' )
    aNamesColumns.push( 'client_name' )
    aNamesColumns.push( 'client_name_user' )
    aNamesColumns.push( 'client_uid' )
    aNamesColumns.push( 'client_name_solution' )
    aNamesColumns.push( 'client_date_login' )
    aNamesColumns.push( 'client_date_idle' )
   

    // Create an empty dataset with a zero row count given an array of column names.
   
    var ds = databaseManager.createEmptyDataSet( 0, aNamesColumns )
   
   
    // Populate the dataset with client data.
   
    for ( var i = 0; i < aClients.length; i++ )
    {
        var CLIENT = aClients[ i ]
       
        var aData = []
       
        aData.push( CLIENT.getClientID() )
        aData.push( CLIENT.getApplicationType() )
        aData.push( CLIENT.getHostAddress() )
        aData.push( CLIENT.getHostIdentifier() )
        aData.push( CLIENT.getHostName() )
        aData.push( CLIENT.getUserName() )
        aData.push( CLIENT.getUserUID() )
        aData.push( CLIENT.getOpenSolutionName() )
        aData.push( CLIENT.getLoginTime() )
        aData.push( CLIENT.getIdleTime() )
       
        ds.addRow( i + 1, aData )
    }
   
   
    // Attach the dataset to the pre-defined in-memory datasource 'user_client_data'.
   
    ds.createDataSource( 'user_client_data' )
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 583
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA


Return to Forms

Who is online

Users browsing this forum: No registered users and 6 guests