Log in to like this post! XamWebGrid Settings Objects [Infragistics] Devin Rader / Friday, July 31, 2009 One of the core architectural concepts in the XamWebGrid is the concept of Settings objects. These objects exist for numerous features of the XamWebGrid and allow us to encapsulate the bulk of the properties for a discreet grid feature into a single object. This makes it easier for you to find and work with those features. As an example, lets look at how you can configure sorting in the XamWebGrid. You can see in the snippet above, to configure the Sorting in the grid, you use the SortingSettings object which contains all of the options for sorting. There are settings objects for: · Add New Row · Column Moving · Column Resizing · Deferred Scrolling · Expansion Indicator · Filtering · Fixed Columns · GroupBy · Paging · Row Selectors · Selection · Sorting Another advantage for using Settings objects is that it allows the control to include the concept of property inheritance. Property inheritance is the notion of setting a property value on some root level object, then having that value trickle down to all of that objects children, who have not explicitly overridden the root level property. Property inheritance becomes useful in the grid when you begin to work with hierarchical data structures. Rather than having to set SortingSettings on each level of your hierarchical structure, you can instead use the SortSettings object exposed on the XamWebGrid control. Property values set on that object will trickle down to each ColumnLayout in the grid. The sample below demonstrates this using the AddNewRowSettings object: <grid:XamWebGrid x:Name="xamwebgrid1" AutoGenerateColumns="False"> <grid:XamWebGrid.AddNewRowSettings> <grid:AddNewRowSettings AllowAddNewRow="Top" /> </grid:XamWebGrid.AddNewRowSettings> <grid:XamWebGrid.Columns> <grid:TextColumn Key="CompanyName" /> <grid:TextColumn Key="ContactName" /> <grid:TextColumn Key="ContactTitle" /> <grid:ColumnLayout Key="Orders"> <grid:ColumnLayout.Columns> <grid:TextColumn Key="OrderDate" /> <grid:TextColumn Key="RequiredDate" /> <grid:TextColumn Key="ShippedDate" /> </grid:ColumnLayout.Columns> </grid:ColumnLayout> </grid:XamWebGrid.Columns> </grid:XamWebGrid> In this sample, I have bound the grid to a hierachical collection of Customers and Orders, resulting in a hierarchical grid structure. You can see that when I enable the AddNewRow using the AddNewRowSettings object, the AddNewRow appears on both the Customers layout and the Orders layout. Of course you may want to override the value of that root level AddNewRowSettings object. This is easily done by setting a different value on the AddNewRowSettingsOverride object exposed by the ColumnLayout. For example, maybe I need to prevent end users from adding new Customers, but allow them to add new Orders, my XAML would look like this: <grid:XamWebGrid x:Name="xamwebgrid1" AutoGenerateColumns="False"> <grid:XamWebGrid.AddNewRowSettings> <grid:AddNewRowSettings AllowAddNewRow="None" /> </grid:XamWebGrid.AddNewRowSettings> <grid:XamWebGrid.Columns> <grid:TextColumn Key="CompanyName" /> <grid:TextColumn Key="ContactName" /> <grid:TextColumn Key="ContactTitle" /> <grid:ColumnLayout Key="Orders"> <grid:ColumnLayout.AddNewRowSettings> <grid:AddNewRowSettingsOverride AllowAddNewRow="Top" /> </grid:ColumnLayout.AddNewRowSettings> <grid:ColumnLayout.Columns> <grid:TextColumn Key="OrderDate" /> <grid:TextColumn Key="RequiredDate" /> <grid:TextColumn Key="ShippedDate" /> </grid:ColumnLayout.Columns> </grid:ColumnLayout> </grid:XamWebGrid.Columns> </grid:XamWebGrid> Settings is an easy, yet essential concept to understand when you get started using the XamWebGrid. Technorati Tags: Silverlight,NetAdvantage