ansoesil’s blog

“Learning is experience. Everything else is just information.” – Albert Einstein

Archive for July 2009

InDepth: Column Layout – Part 1

with one comment

Hi,

In the previous posts i’ve discussed how to do data binding using Intersoft Presenter. One thing that is set by default is that the columns is automatically generated from the given item type. In most cases, we don’t want all the columns in the item type to be displayed so how can we manage this ?

Intersoft Presenter has the capability to determine the view definitions through several properties. First of all you can defines the columns that you want to display, controls its behavior (AllowFilter, AllowGrouping, AllowSort), its display (Caption, Width), its action (SortMemberField, FilterMemberField), including states such as SortOrder and so on. Furthermore you can also control the FilterOptions which contains collection of option that can be used to filter the data, and you can also determine which options are checked and which options aren’t. Last but not least you can also control the group columns.

In this post I’ll cover three basic approach to define the column layout:

  1. Declaratively in the xaml.
  2. Programmatically.
  3. Change layout at runtime.

Defining column layout declaratively in the xaml

InDepth-ColumnLayout1

First of all you need to turn of the AutoGenerateColumn property (set the value of this property to “No”). Then you’ll need to define the columns manually as in the picture above.

InDepth-ColumnLayout1b

To specify the initial order position you can do:

InDepth-ColumnLayout1c

The default value is “None” which mean no SortOrder is applied.

Further more you can also customize the filter options that will be listed in the action box by declaring:

InDepth-ColumnLayout1d

You’re free to create any set of Expression in each filter option, and then specify the meaningful name to its Filter Text. In this case i would like to filter the data base on certain range of value.

Furthermore you can also set which of the following options that will be applied initially and which aren’t by filling the SelectedFilterOptions property.

InDepth-ColumnLayout1e

The SelectedFilterOptions should be filled with FilterOption that will be applied / checked which linked through FilterText. As for this case, the 0 – 50 options will be checked while the 51 – 100 option will not.

InDepth-ColumnLayout2

And as you can see from the screen shot, the Units in order column is also sorted descending.

Lastly you can also specify the grouped columns from:

InDepth-ColumnLayout3

This approach give you more freedom to set the initial display of you Presenter. There are also others property that i didn’t cover up in this post but all of them can configurable the same way.

I”ll discuss how to specify column definitions programmatically and how to change it at run time and what are the things to considered when changing the column definitions in the next post.

Regards

Andry

Here’s are the link to the sample code.

Written by ansoesil

July 22, 2009 at 9:09 pm

In Depth: Data Binding with Intersoft Presenter for Silverlight – Part2

with one comment

Hi all,

In the previous post we discuss about the various factor that you can do with data binding with intersoft presenter. Now i want to discuss about how to add additional query / custom query and how to change the data source of intersoft presenter at run time.

Using custom query

Often in developing an application we perform more complex query rather just selecting all the data and display it, and how can we achieve that using Intersoft Presenter and Intersoft Data Source?

As mentioned before there are two types of data binding in Intersoft Presenter:

  1. Bound to Intersoft Data Source control.
  2. Unbound to Intersoft Data Source control.

In unbound to Intersoft Data Source control, the developer only need to specify the ItemSource with the processed data source, so developer is responsible to give the ItemsSource with the correct data.

In bound to Intersoft Data Source control, the developer can interrupt the selecting process using Intersoft Data Source’s Selecting event handler and provide the custom query there.

InDepth2-DataBinding

Attach Selecting Event

Add the custom query at code behind.

InDepth2-DataBinding1

InDepth2-DataBinding2

Note that you might want to keep some of the sort / filter / paging expression from the actual data source select arguments. The above code shows you how to initialize the query and then put the custom / additional filter after it.

In this case i’m adding additional filter (Discontinued == false) so that it will shows Products data with page size of 20 and filter-out the discontinued products.

Changing Data Source at runtime

We also often developing an application where it requires us to change the data source of our presenter, you can do that by changing the data member of your presenter (for Bound to Intersoft Data Source control scenario) and call RefreshData(true) method, or you can specify the new ItemsSource using RefreshData(newItemSource, true) for Unbound to Intersoft Data Source control scenario.

InDepth2-DataBinding3

During combox box items selection changed:

InDepth2-DataBinding4

Results:

InDepth2-DataBinding5

InDepth2-DataBinding6

If you want to see the sample code, you can download it from here.

Regards

Andry

Written by ansoesil

July 17, 2009 at 12:57 pm

Posted in General

In Depth: Data Binding with Intersoft Presenter for Silverlight – Part1

with one comment

Hi all,

Silverlight 3.0 RTM is released and there are lots of new exciting features including the Microsoft .NET RIA services which give us a new way to perform data binding to Silverlight application.  I’ll cover this area later in other posts, as we still exploring the Silverlight 3.0 so stay tune.

In this post i would like to focus on the current data binding approach that we implement in Intersoft Presenter for Silverlight. There are two ways to perform data binding in Intersoft Presenter for Silverlight:

  1. Bound to Intersoft Data Source control.
  2. Unbound to Intersoft Data Source control.

What does it mean with “Unbound to Intersoft Data Source control” ?

Unbound to Intersoft Data Source control means that your presenter is not attached to any data source control, which required the developer to provide the data through ItemSource property.

InDepth-DataBinding1

You can also use Intersoft Data Source control to populate the ItemsSource to get the data from Astoria Data Service / WCF Data Service / XML.

InDepth-DataBinding2

Since the process is asynchronous, you need to assign the ItemsSource at Selected event as described above.

Using this approach, the presenter will only get the data once and all build-in data operation (filtering / sorting / paging) will be processed using client side operation which mean no data transaction to server again as displayed below.

InDepth-DataBinding3

This approach can be useful, if you can grab all the data at once during the first request. However if you’re dealing with enterprise data where paging is required because the data is too large, its probably best using the “Bound to Intersoft Data Source control” mode so that only partial data is sent from server to client per request (note: using paging approach).

How Bound to Intersoft Data Source control differs with Unbound mode ?

Bound to Intersoft Data Source control means that all the data operation is delegated to Data Source control. The Presenter only need to specify two properties which are DataSourceID and DataMember to point which data service responsible for the Presenter.

By default the all data operation will be requested back from the server through DataSource control, this is design to support the enterprise scenario which most likely will use paging to suppress the data transaction as minimum as possible. However you can also turn the mode into client side operation if you prefer, which force the Presenter to request the data only once at the first call and later all the data operation will be using client side operation as in unbound mode.

InDepth-DataBinding4a

If you check using HTTP Watch or HTTP Fox (for Firefox), you’ll see that there are some data transaction whenever you perform filtering / paging / sorting.

InDepth-DataBinding5

As you can see from the screen shot, bytes sent are relatively small because the data sent is only 20 records per page. You might want to consider this approach if you’re developing enterprise application.

Although Intersoft Presenter has nice feature called Virtual Scroll to overcome scrolling large data issue, its always good idea to consider the data transaction between client and server. This is just one of many approach that you can choose to develop your application.

I’ll discuss more on how to customize the query for data selection, changing the data source with / without structure changed at runtime in part2.

If you want to see the sample code, you can download it from here.

Regards

Andry

Written by ansoesil

July 14, 2009 at 10:13 am