Adding a Custom Row to a VDF Grid


A while back, I showed you how to write a custom column for your VDF grid.  But what about a custom row?  Can it be done?  If the answer was No, this would be a pretty short blog article, so the answer is Yes!

Just like with custom columns, this data is client-side only.  It’s not saved to the server or shared with other Vault clients.

Let’s just dive right in to code again.  For this example, I’ll put a custom row in the grid followed by a standard File row.


If you already know how to populate the VDF grid with Entity objects, you are more than halfway there.  The only new steps are creating the EntityClass and Entity class.  Those are two different things, by the way. 

EntityClass is the type of entity.  For example, File, Folder, Item, Change Order or Custom Object.  For this example, let’s create our own EntityClass.  You can easily do this by calling AddInternalEntityClass.  You pass in a unique ID and display name, and you will get back an EntityClass of you very own.  Although this is a custom entity class, it’s not a Custom Object.  Custom Objects are stored on the server.

// create our entity class.
EntityClass
myEntClass =
    m_conn.ConfigurationManager.AddInternalEntityClass(
   
"MyClass", "My Class");

Now let’s create our Entity class, which we do by deriving from IEntity. I’m just going to create something simple for demonstration purposes.

classMyEntity : IEntity

{

    public MyEntity(EntityClass entityClass)

    {

        m_entityClass = entityClass;

    }

 

    privateEntityClass m_entityClass;

    publicEntityClass EntityClass

    {

        get { return m_entityClass; }

    }

 

    publiclong EntityIterationId

    {

        get { return -1; }

    }

 

    publiclong EntityMasterId

    {

        get { return -1; }

    }

 

    publicstring EntityName

    {

        get { return"My entity name"; }

    }

 

    publicbool IsCloaked

    {

        get { return false; }

    }

 

    publicLink LinkInfo

    {

        get

        {

            return null;

        }

        set

        {

               

        }

    }

}

Now we are free to create any number of MyEntity objects and place them in our grid, just like any other IEntity.  Most of this code just involves setting up the grid.  Only a couple of lines are related to our custom entity.

// create our entity objects.

MyEntity myEnt = newMyEntity(myEntClass);

 

 

// Let’s grab a file too.

File file = m_conn.WebServiceManager.DocumentService.FindLatestFilesByPaths(
"$/Inventor/Designs/Padlock/Assemblies/Pad Lock.iam".ToSingleArray()).First();

FileIteration fileIter = new FileIteration(m_conn, file);

 

 

// standard setup for a grid control

string persistanceKey = "ServiceAttributeTest.PropsTest";

VaultBrowserControl.Configuration config =

    newVaultBrowserControl.Configuration(
        m_conn, persistanceKey,
null);

 

// Set the Name property as the grid’s only column.
// All entities have a Name property.

config.AddInitialColumn(PropertyDefinitionIds.Server.EntityName);

config.AddInitialSortCriteria(
PropertyDefinitionIds.Server.EntityName, true);

 

ViewVaultNavigationModel viewModel =
   
newViewVaultNavigationModel();

 

// Add in the File and MyEntity objects as the grid content

List<IEntity> content = newList<IEntity>();

content.Add(fileIter);

content.Add(myEnt);

 

// Set the content and show the grid

viewModel.SetContent(content);

m_vaultGrid.SetDataSource(config, viewModel);

m_vaultGrid.Refresh();



Comments

2 responses to “Adding a Custom Row to a VDF Grid”

  1. It’s a crying shame that the results of all this awesome VDF goodness can’t be passed to any of the existing Vault commands such as Send File.
    Even when you put a VDF control into a Vault tab, all of the normal Vault commands are greyed out. From a UX standpoint that is quite strange, since the rest of the default tabs don’t behave that way from the user’s perspective.
    We don’t think there is, but are you aware of a work around? one which doesn’t involve re-writing/creating the native Vault commands in our own code. (Not all of the calls made by the Send File command are supported in the API).

  2. No, there is no way to hook your VDF grid to existing Vault Explorer commands.
    It’s a good idea, and you should post it in the Vault Idea Exchange. http://forums.autodesk.com/t5/Vault-IdeaStation/idb-p/2

Leave a Reply