NetAdvantage for Web Client: Silverlight - November CTP

[Infragistics] Devin Rader / Monday, November 09, 2009

Hot on the heels of the 2009.2 release of NetAdvantage for Web Client, we are ready to push some more code out the door in our November Community Technology Preview (CTP).  This CTP includes several new XamWebGrid enhancements including support for RIA Services, a new ZIP Library, a control persistence framework and an early preview of our new XamWebRibbon control.  Check out the CTP samples on-line or read on for more information about what's in the CTP. 

Download the CTP | View the Samples

XamWebGrid – Unbound Column

One of two new column types in the the XamWebGrid, the UnboundColumn, unlike existing columns in the XamWebGrid, does not require you to bind it to a property of the underlying items source.  This means you can now add things like calculated columns to your grid.  For example, if I have a grid that is bound to a collection of Line Item objects, each of those objects may only know about the per unit cost of the product and the quantity ordered.  It would be nice to show the subtotal of each Line Item in my grid without having to modify the Line Item object:

image

To do that I can simply add an Unbound column and supply a ValueConverter to it that calculates the subtotal value using the Price and Quantity values:

<iggrid:XamWebGrid x:Name="xamWebGrid">
    <iggrid:XamWebGrid.Columns>
        <iggrid:TextColumn Key="Price" />
        <iggrid:TextColumn Key="Quantity" />
        <iggrid:UnboundColumn Key="Net" 
                ValueConverter="{StaticResource PurchaseNetTotalCalculator}" />
    </iggrid:XamWebGrid.Columns>
</iggrid:XamWebGrid>

XamWebGrid – TemplateLayoutColumn

The next new feature of the XamWebGrid in this CTP is the TemplateLayoutColumn.  This new column type allows you to create custom DataTemplates that define a custom layout of rows in the grid.  This allows you to show an initial subset of commonly viewed data, then expand the row to show a detailed data view:

image

Using the TemplateLayoutColumn is as easy as any other column type in the XamWebGrid.  You simply add the TemplateLayoutColumn to the grid Columns collection and define a DataTemplate:

<iggrid:XamWebGrid x:Name="customersGrid" 
    AutoGenerateColumns="False" Margin="0">
    <iggrid:XamWebGrid.Columns>
        <iggrid:TextColumn Key="Company" />
        <iggrid:TextColumn Key="ContactName" />                
        <iggrid:TemplateColumnLayout Key="CustomerID" 
                Template="{StaticResource CustomRowTemplate}"/>
    </iggrid:XamWebGrid.Columns>
</iggrid:XamWebGrid>

The data context of the TemplateLayoutColumn is the data object bound to the row, so you have access to any of the row data from within the template.

XamWebGrid – RIA Services Integration

Finally for the XamWebGrid, we are very happy to release in this CTP not just support for, but direct integration with Microsoft's RIA Services in the XamWebGrid.  This means that you can now use a DomainDataSource as the ItemSource for the XamWebGrid and when you do the control will automatically detect this and perform operations such as paging, editing, sorting and grouping through the DomainDataSource.  Additionally, the grid will automatically reflect in its UI any paging settings and SortOperands that you have defined in your DomainDataSource.

<dds:DomainDataSource 
    x:Name="dds" AutoLoad="True"
    QueryName="GetCustomersQuery"
    LoadSize="20" PageSize="10">            
    <dds:DomainDataSource.DomainContext>
        <web:NorthwindContext />
    </dds:DomainDataSource.DomainContext>
    <dds:DomainDataSource.SortDescriptors>
        <riaData:SortDescriptor PropertyPath="CustomerID"
                                Direction="Ascending" />
    </dds:DomainDataSource.SortDescriptors>
</dds:DomainDataSource>

<iggrid:XamWebGrid ItemsSource="{Binding Data, ElementName=dds}">
    <iggrid:XamWebGrid.PagerSettings>
        <iggrid:PagerSettings AllowPaging="Bottom" 
                              DisplayPagerWhenOnlyOnePage="False" />
    </iggrid:XamWebGrid.PagerSettings>
    <iggrid:XamWebGrid.GroupBySettings>
        <iggrid:GroupBySettings AllowGroupByArea="Top"/>
    </iggrid:XamWebGrid.GroupBySettings>
</iggrid:XamWebGrid>

In a future CTP we will also add full support for performing filter operations using the DomainDataSources FilterOperands in the grid as well.

XamWebRibbon

A new navigation control, the XamWebRibbon control replicates the look and feel and behavior of the Office 2007 Ribbon control in a 100% native Silverlight control.  This CTP includes the ability to create Tabs and add Button Tools to Tabs and the Application menu.  You can also add tools to the Quick Access Toolbar (QAT).

image

As we continue to work on this control in future CTP’s you will see support for Contextual Tabs and additional tool types like Galleries.

Control Persistence Framework

The Control Persistence Framework (CPF) is a new framework we’ve been working on that allows you to persist control settings to an external source (like a file or a database).  This comes is useful when you want to save end users settings (things like column widths and positions in the grid, the selected group in the XamWebOutlookBar, or the position of the XamWebDialogWindow), then reload them when they return to to the application.  If you are familiar with the Load/Save Layout functionality that we offer in some of our other controls on the Windows Forms platform, the CPF is designed to give you that same functionality in Silverlight.

Additionally, we’ve designed this framework so that it is not only capable of saving the settings of Infragistics controls, but any control or object in your application, so if you are mixing in native Microsoft controls or your own custom controls, you can still use the CPF to persist settings of those controls and reload them at a later point.

ZIP Library

Finally in this CTP we are releasing a new ZIP Library assembly.  This assembly includes a replication of the GZipStream and DeflateStream classes that are found in the full .NET Framework, plus an additional stream for the ZLib compression algorithm.  The library also includes additional new API’s that make it simple to create ZIP files within your Silverlight app:

private void btnCreate_Click(object sender, RoutedEventArgs e)
{
    OpenFileDialog open = new OpenFileDialog();
    open.Multiselect = true;

    bool? dialogResult = open.ShowDialog();
    if (dialogResult == true)
    {
        
        foreach (FileInfo file in open.Files)
        {
            zip.AddEntry(file.Name, 
                System.IO.Path.GetDirectoryName(file.Name), "");
        }
    }
}

Conclusion

There are lots of great new features packed into this CTP, and we would love to have your feedback on any or all of them in our forums.  You can also see samples for each new feature online at https://www.infragistics.com/samples/silverlight

Download the CTP | View the Samples