FogBugz Plugin Interfaces > Filters > IPluginGridColumn
This article will demonstrate a simple FogBugz plugin that implements the IPluginGridColumn interface contained in the FogCreek.FogBugz.Plugins.Interfaces class library.
This plugin adds a table, Kiwi and joins it to the Bug table (see Implementing IPluginDatabase and Implementing IPluginBugCommit, IPluginBugDisplay, IPluginBugJoin) for the purpose of demonstrating the addition of two columns to the grid view. It does not provide an interface to add entries to the Kiwi table. To do that, see Implementing IPluginDatabase. For a more advanced treatment involving joining a table in the database and allowing filtering based upon it, see Implementing IPluginGridColumn, IPluginFilterJoin...
IPluginGridColumn requires implementation of four methods:
- GridColumns() returns the information about the columns you want to create: name, title, etc. use the iType CGridColumn property to give each a unique integer key. In the other methods, use a switch statement on that
- GridColumnQuery(CGridColumn col) returns the CBugQuery used to get the data you want in the column. The query only needs to join in your data if it is not already done in IPluginBugJoin.
- Next, you need to define what is going to be displayed with GridColumnDisplay(CGridColumn col, CBug rgBug, bool fPlainText) For example, if you're fetching an email address from the database, you may want to return an html link. Remember to HtmlEncode anything coming out of the database.
- The last method is for when the column is sorted, CSelectQuery GridColumnSortQuery(CGridColumn col, bool fDescending, bool fIncludeSelect). It should call the same function as the select, and just add the orderby. It should also only select if fIncludeSelect is true and your table is not joined automatically via IPluginBugJoin.
This plugin will create and join a new table "kiwis" and add the fields to the filter drop-down so they may be displayed as columns in the grid view.
Compile and Install It On Your Own
Download the source file: IPluginGridColumn_Example.cs
Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin