Documents

NextGrid & NextDBGrid

NextGrid

NextDBGrid

NextInspector

NextSheet

NextCollection

Misc

Labs

NextGrid .NET

FieldChooser Tutorial

Related Articles:

Info
  • Skill:
  • Version: 1.0.1
  • Author: Bojan Nikolic
  • Created:
  • Updated: 2008-04-26
In this article we will explain how to work with Field Chooser component. With using Field Chooser component users are able to Show and Hide Columns in Run-Time!

Developer first need to define Fields (Columns) Categories, and then place single Columns inside this Categories. Users will be able then to drag and drop hidden columns from Field Chooser back to Grid and make this Column Visible!



Each Column may be placed in single or in several Categories, or there can be only one Category with all Columns.

1. Place component of form



Field Chooser (TNxFieldChooser) component is located inside "Next Suite" Tab/Category on Components Pallete. Double click on Field Chooser icon and component will be placed on Form.

Now place one NextGrid component and point Associate property of Field Chooser to this Grid, or some other existing NextGrid. Grid and Field Chooser doesn't need to be placed on same form.

2. Set column Categories



Field Chooser require at least one Category, but sometime is usefull to have several Categories inside Field Chooser.

Each Category have own Columns Collection and own Caption. To add new Category (and set Caption in same line) write:

NxFieldChooser1.AddCategory('Frequently-used Fields');


To delete Category write:

NxFieldChooser1.DeleteCategory(CategoryIndex);


To set Category Properties, user Categories array property:

NxFieldChooser1.Categories[CategoryIndex]...


Only one Category may be active in same time, to change Active Category, set Category property:

NxFieldChooser1.Category := CategoryIndex;


3. Add Columns into Category



After we have create Category, we can now add Columns inside it. Same Column may be in several categories.

To place Column inside Category, use Add method of Category:

NxFieldChooser.Categories[CategoryIndex].Add(NextGrid1.Columns[ColumnIndex]);


or you can add Column in same pass when adding Category:

with NxFieldChooser1.AddCategory('Common Fields') do
begin
  Add(NxTextColumn1);
  Add(NxTextColumn2);
  ...
end;


To add all Columns into Category, write:

NxFieldChooser.Categories[CategoryIndex].AddAllColumns;


If Column is already Hidden and we set this Category as current Category, Column's "Box" will be show inside Field Chooser and User will be able to drag it to the Grid.

To remove column from Category, use Delete method of Category:

NxFieldChooser.Categories[CategoryIndex].Delete(Index);


Conclusion



With using FieldChooser component your users will be able to more easy customize their Grids and you no more need to create own customizers. In upcoming versions we will add possibility for customizing Column's Alignment, Size...by double clicking on Column Box inside FieldChooser.

For more details download demo project source.

Was This Article Useful?

Only constructive comments, code contributions... will be publishes. Questions, non-official discussion will not be published.