Reducing Column Processing
By default RadGridView will fetch all bindable properties from the data source you use for control structure generation. These properties will be also be used in sorting, filtering, grouping or other operations. In some cases you may not need your grid instance to iterate through all the fields in your data source upon binding. Generally, this can be a requirement when you have custom collection of business objects which you pass to the DataSource property of RadGridView to generate its content.
To prevent the grid from traversing all data fields in that collection, set the GridViewTemplate.AutoGenerateColumns property to False. In this case, the additional fields that you might use when sorting, grouping, etc., should be included in the MasterGridViewTemplate.Columns collection. With these settings, only the properties that are used as column FieldName properties or those specified in the MasterGridViewTemplate.Columns will be extracted.
Alternative Binding to Custom Collections
Currently RadGridView supports sorting, filtering and grouping natively. This is represented by three collections of corresponding expressions:
These features are not tightly coupled with the column declarations of the grid but with the data that the grid is bound to.
To clarify the idea, consider the following scenario. You want to display a list of all files in a directory. For this purpose you use
FileSystemInfo from the System.IO.FileSystemInfo namespace. This collection has many properties:
Attributes, CreationTime, CreationTimeUtc, Exists,
Extension, FullName, LastAccessTime, LastAccessTimeUtc,
LastWriteTime, LastWriteTimeUtc and Name. This is a long list that you probably
don't want to expose in the grid. Instead you define the columns to be displayed and supply the GridView DataSource with the files information:
[C#] Adding to the Columns Collection
radGridView1.MasterTemplate.AutoGenerateColumns = false;
DirectoryInfo directory = new DirectoryInfo("C:\\");
FileSystemInfo filesInDirectory = directory.GetFileSystemInfos();
radGridView1.DataSource = filesInDirectory;
[VB.NET] Adding to the Columns Collection
RadGridView1.MasterTemplate.AutoGenerateColumns = False
Dim directory As New DirectoryInfo("C:\")
Dim filesInDirectory As FileSystemInfo() = directory.GetFileSystemInfos()
RadGridView1.DataSource = filesInDirectory