.Net, ASP.Net, C#, VB.net, SQL Server, Xml, CSS, Design Patterns related tips, tricks, code snippets, articles, links, thoughts, etc. from Binu & Subi Thayamkery.

Binu Thayamkery is a seasoned software architect with more than 13 years of experience in developing enterprise grade connected systems using Microsoft Technologies. In his current position as a lead consultant-solution architect with Prudential Financial, he is working on architecture of next generation investment reporting framework using .net 3.5/WCF/AJAX, etc. He holds a Masters Degree in Computer Science from Colorado State University. Subi Thayamkery is an experienced software developer with more than 8 years of developing various application software systems ranging from workflow automation systems to compliance management tools. She currently works as a technology consultant for Prudential Financial where she helps develop a new system for corportate governance department. She holds an Electrical Engineering degree from New Jersey Institute of Technology.

Thursday, June 01, 2006

Infragistics Net Advantage 2005 Vol 3 - Tips and Tricks - Part 1

1) For development, always install the complete product, dont try to copy the Infragistics assemblies script files manually to set up your dev machine. A proper install will make sure that the components are added to your VS.Net IDE toolbox. If your install fails to do this, there is a command line utilty provided (available from Infragistics Program Group) with the product that will add VS.Net toolbox tab.
If you are upgrading Infragistics from an older version to newer version, make sure to upgrade your project files using .Net Project Upgrade Utility (also found in Infragistics Program Group). Make sure that you have all the latest hot fixes applied (to avoid nasty surprises). A complete installation will also install
help files, regsiter them propery, it also comes with a nice Samples Browser with a lot of working samples.

2) First time when you starting your development with Infragistics, (for example UltraWebgrid), you set your references to the required assemblies, dragged the control on to your form and ran it. If you get a runtime error pointing to missing "BorderStyle" class/namespace reference, you probably need to set "CopyLocal" property for the WebUI assembly to True. To do this locate Infragistics.WebUI.Shared.v5.3, right click and Properies, set CopyLocal to true.

3) Infragistics provides you a very rich UI experience. How does it do it? It uses a mix of client side javascripting and server side programs. Infragistics comes with a neat collection of client side javascript library for each of its controls. This provides rich client side features. It is AJAX enabled, and makes out-of-band calls to server to load data when the control's properties are set to use that feature. When you intsall the product (example: Ver 2005 Vol 3)
you will notice that a virtual directory named "ig_common" is created for you. This virtual directory hosts the required javascript files and other resources that are required for running Infragistics controls.

4) Discussion of the previous point leads us to the deployment of applications that uses Infragistics, For a simple deployment follow these steps,

  • Copy the Infragistics Assemblies that are used by your application to a install folder in your server. These are signed assemblies. Add these to Global Assembly Cache (GAC).

  • Copy the directory that is pointed by ig_common virtual directory in your dev
  • Create a virtual directory in your server, point it to the folder explained in the previous step.

  • Build your application that uses Infragistics, deploy it to the server ( which ever way you choose, xcopy, copy project..)



5) Page.SmartNavigation - Set this to False from design view. I have seen many developers complaining about this feature in v1.1. Setting this property to true is not recommended (so I was told by Infragistics Support once!)when your page has Infragistics components. If you want to preserve the scroll position on your page use some Javascript technique.

6) UltraWebGrid - Simple Binding - Works pretty much the same way as a regular ASP.Net grid. Please remember that UltraWebgrid can have multiple bands (virtual grids within grid) and columns collection is within the Band. Another important property is DisplayLayout. Most of the UI elements are defined within this. If you are binding the grid on the fly relying on the underlying datasource for columns, Set DisplayLayout > AutoGenerateColumns to True. You can also choose to add columns design time, setting the data field names for each columns, in that case set AutoGenerateColumns to False.

Example:

myGrid.DataSource = myDataSet.Tables[0].DefaultView;
myGrid.DataBind();

Once the DataBind() is done, the grid fires "InitalizeLayout" event. This is one event you can hace code to handle some useful
properties of the grid. This can be a good place to handle setting the column widths, making some columns hidden, setting "keys"
for columns, turning on/off sorting for columns, handling header captions and style to name a few.


//Do not forget to import the namespace
using Infragistics.WebUI.UltraWebGrid;
using Infragistics.WebUI.Misc;
:
:
//Examples of setting keys for columns; you can use the key to grab handle to this column
myGrid.Bands[0].Columns[0].Key = "Check";
myGrid.Bands[0].Columns[1].Key = "Id";

//Setting Align
myGrid.Bands[0].Columns[0].CellStyle.HorizontalAlign = HorizontalAlign.Center;

//Setting width
myGrid.DisplayLayout.Bands[0].Columns[0].Width = Unit.Pixel(30);

//setting click action on header
myGrid.DisplayLayout.Bands[0].Columns[0].Header.ClickAction = HeaderClickAction.NotSet;

//Setting Header Caption
myGrid.DisplayLayout.Bands[0].Columns[0].Header.Caption = "My Caption";

//set sort for all bands and columns of the grid to "No Sort"
myGrid.DisplayLayout.HeaderClickActionDefault = HeaderClickAction.NotSet;



More coming sooon....

0 comments: