Aug 2, 2009

WebPart Connections With Power WebPart 3.0

Web Part connections in SharePoint allows you to connect different Web Parts and to exchange data between them, even if they are from different suppliers. This is possible through the ASP.NET WebPart Connection Framework and some interfaces. For sure Power WebPart supports Web Part connections. It can act either as a row and table provider or as a consumer.

image

The example shows on the left a Power WebPart using a SPGridView to display current processes and acts as a row provider. It uses a DataTable as data source and sends the selected DataRow to the consumers. Theoretically you can send any object, but PowerShell dynamic types/properties (add-member) behave different and can not be reflected by the Web Part Connection Framework, so I recommend using DataTables and DataRows for WebPart connections ( in PowerShell 2.0 you can alternatively use add-type to generate C# types on the fly). On the right you see two consumers, a Power WebPart and a SharePoint List View WebPart. Both consume the DataRow from the provider on the left. The Power WebPart consumer simply shows the first column and the SharePoint List View uses the “Name” column of the provided row to filter the list items.

A script says more than thousand words.

The row provider web part:

# SPGridView to display the result 
$gridView = New-Object Microsoft.SharePoint.WebControls.SPGridView

# DataTable is used as data container
$table = New-Object System.Data.DataTable("Container")

function CreateChildControls($controls)
{ 
# add columns to the table
$table.Columns.Add($(New-Object System.Data.DataColumn("ID",[Int32])))
$table.Columns.Add($(New-Object System.Data.DataColumn("Name",[String])))
$table.Columns.Add($(New-Object System.Data.DataColumn("CPU",[double])))

# fill the table with processes
foreach($p in $(get-process))
{
$row = $table.NewRow()
$row.ID = $p.ID
$row.Name = $p.Name
$row.CPU = [double]$p.CPU

$table.Rows.Add($row)
}

# add columns to the SPGridView
$colSelectButton = New-Object System.Web.UI.WebControls.CommandField
$colSelectButton.HeaderText = "Action"
$colSelectButton.SelectText = "select"
$colSelectButton.ShowSelectButton = $true
$gridView.Columns.Add($colSelectButton)


$colId = New-Object Microsoft.SharePoint.WebControls.SPBoundField
$colId.HeaderText = "ID"
$colId.DataField = "ID"
$gridView.Columns.Add($colId)

$colName = New-Object Microsoft.SharePoint.WebControls.SPBoundField
$colName.HeaderText = "Name"
$colName.DataField = "Name"
$gridView.Columns.Add($colName)

$colCPU = New-Object Microsoft.SharePoint.WebControls.SPBoundField
$colCPU.HeaderText = "CPU"
$colCPU.DataField = "CPU"
$gridView.Columns.Add($colCPU);

# configure SPGridView
$gridView.AutoGenerateColumns=$false
$gridView.DataSource = $table
$gridView.DataBind()

$controls.Add($gridView)
}

# returns the schema to the WP Connection Framework
function GetSchema
{  
# return an empty row (or type, used for reflection)
return $table.NewRow()
}

# sends the selected row to the WP Connection Framework
function SendRow
{ 
if($gridView.SelectedIndex -gt -1) 
{
return $table.Rows[$gridView.SelectedIndex]
}
else
{
# return $null when nothing is selected
return $null
}
}

The row consumer web part:

$label = New-Object System.Web.UI.WebControls.Label

function OnReceiveRow($row, $schema)
{
if ($row -ne $null){$label.Text= $row[0]}
}

function OnPreRender
{ 
# request the row from the web part connection
# will fire "OnReceiveRow" 
Query-Connections 
}

function Render($writer)
{
$writer.Write("

") $label.RenderControl($writer) $writer.Write("

") }

WebPart Connections work with Power WebPart 3.0 build 0908020651 or greater.

24 comments:

Anonymous said...

Hallo,

tolles Beispiel, vielen Dank.

Wie kann ich die Spalten sortieren oder filtern?

Alle API-Befehler die ich kenne, verlangen einen Callback, den ich in PowerWebPart 3 nicht eingebunden bekomme.

Gibt es einen Trick?

Vielen Dank und freundliche Grüße,

Lemelisk

Anonymous said...

hello Christian

I tried installing Power WebPart 3.0 but I receive this error message when adding a web part


Error on Initialization
Exception:
Invalid URI: The URI is empty.
Stack:
at iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) at iLoveSharePoint.WebControls.PowerWebPart.Render(HtmlTextWriter writer)


Any ideas?

thanks

Anonymous said...

Christian

I tried to install Pwer Webpart 3 but I receive this error when I attempt to add a web part:

Error on Initialization
Exception:
Invalid URI: The URI is empty.
Stack:
at iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) at iLoveSharePoint.WebControls.PowerWebPart.Render(HtmlTextWriter writer)

Christian said...

Hello, this isn't an issue. The message will disappears when a farm admin first clicks on apply or okay in the WP Editor. By default the script is not signed - security.
bye, Christian

Anonymous said...

Thanks for the reply Christian. What I want to add is a Tag cloud. can I do that with Power WebPart 3.0? When I add the webpart it just displays a link to iLove SharePoint.
thanks

Christian said...

Hello, check out this post http://cglessner.blogspot.com/2009/05/power-tag-cloud-sharepoint-tag-cloud.html
Bye, Christian

Anonymous said...

Nice example, works like a charm :)

local marketing said...

Appreciate it with the answer Orlando. Just what I would like to add is often a Label cloud. can one accomplish that local marketing along with Strength WebPart 3. 0? Once i add this webpart it just features a web link to help i Love SharePoint.

maymay said...

You could enjoy life THESE DAYS! You will have unending opportunity throughout everyone and also solutions that will chanel replica together with undertake anything you would like. Any shorter activity That i procured everyone thru meant for phobias is only a good place to begin meant for having the capability to enjoy life these days. That i will allow you to utilizing reducing specific guidelines, romances, tobacco use, weightloss, together with so much more points that always keep everyone with history all by yourself a good chanel replica over the joy and happiness weighing machine. An exceptionally good friend for my service is telling "when you what you may undertake, installed really need to job each and every day in your own life". It’s a good mantra together with insurance quote having wedged beside me for a few years these days together with key phrases for knowledge That i are located by just and now have imparted that will my best boys and girls together with people identical. The manner in which That i see it is certainly you will have as a minimum several chanel replica. You decide on an individual's bliss or simply fire from a work or simply past time also, you go for it or simply everyone find a way to generally be keen related to your own work. Below are some systems that will help get an individual's fire: Approval Test – Consider every one space ever experience together with find out an individual's volume of approval utilizing every one space. Think about your career, money situation, health and wellness, chanel replica in your boyfriend or girlfriend, loved ones, unique growing together with chanel replica, bricks-and-mortar surrounds, interesting together with relaxation together with anything different that could be crucial for you to everyone.

electronic signature sharepoint said...

Regualer sharepoint in the market gives a better investment with a great opportunity in the market services for best option in the market. thanks

Raj Joshi said...

Happy Rose Day 2016 Images Pics,
Rose Day Quotes Wishes SMS Messages,
Happy Rose Day Images Free Download
When is Rose Day 2016 in India
Calendar Date of Rose Day
Short Note on Rose Day

Hug Day said...

happy hug day 2016
happy hug day 2016 Date SMS Messages Quotes
Hug day Celebration Ideas
hug day sms for bf/gf

风骚达哥 said...

20160423 junda
air jordans
cheap oakley sunglasses
kate spade outlet
adidas stan smith
ray ban sunglasses
michael kors outlet
nike air max shoes
cheap omega watches
yeezy boost 350
michael kors outlet online
michael kors outlet online
nike free runs
air jordan uk
michael kors outlet online
pandora charms
ray ban outlet
calvin klein outlet
fitflops sale clearance
toms outlet
nike huarache white
sac longchamp
toms outlet
michael kors outlet clearance
bottega veneta outlet
armani watches
gucci handbags
nike blazer
oakley sunglasses
true religion jeans
cheap jordans
ray bans
hollister
bottega veneta handbags
jimmy choo outlet
oakley sunglasses
converse
prada outlet
reebok shoes
true religion
burberry outlet

Yuanyuan Lin said...

7.14lllllyuan"tiffany and co"
"michael kors outlet"
"hollister uk"
"michael kors outlet"
"salomon shoes sale"
"ralph lauren outlet"
"bottega veneta outlet online"
"fred perry polo"
"true religion jeans"
"michael kors outlet"
"camisetas futbol baratas"
"cartier outlet store"
"hollister"
"christian louboutin shoes"
"nike soccer shoes"
"polo ralph lauren"
"polo ralph lauren"
"michael kors outlet"
"longchamp handbags"
"fitflops sale"
"michael kors outlet"
"coach outlet online"
"louis vuitton handbags outlet"
"adidas shoes"
"tory burch shoes"
"chrome hearts eyewear"
"tory burch outlet"
"michael kors outlet"
"replica watches"
"burberry sunglasses on sale"
"louis vuitton bags"
"coach outlet"
"jordan shoes 2015"
"michael kors outlet"
"abercrombie outlet"
7.14

Fangyaya said...

michael kors purses
christian louboutin outlet
burberry handbags
coach outlet online
fitflop clearance
jordan 3s
michael kors
michael kors outlet
air jordan 8
replica rolex watches
adidas outlet store
michael kors outlet clearance
retro 11
cheap true religion jeans
cheap true religion
nike air max uk
replica rolex watches
christian louboutin shoes
supra footwear
louis vuitton bags
designer handbags
polo ralph lauren
cheap basketball shoes
adidas originals
coach outlet store online
coach outlet
cheap jordan shoes
oakley vault
jordan retro 4
coach factory outlet online
louis vuitton outlet
air jordan shoes
ed hardy outlet
gucci handbags
adidas yeezy
kobe shoes
discount jordans
cheap jordans
oakley sunglasses
coach factory outlet online
20168.8chenjinyan

Justin said...

Government solidification advances, with their low financing costs don't reach out to private instructive advances. In any case, there are various choices for the individuals who look for the renegotiating of private instructive credits. payday loans

dada24 Xu said...

cheap oakleys
ralph lauren pas cher
canada goose
michael kors outlet clearance
true religion outlet
armani exchange
gucci outlet
ed hardy
ugg boots
ray ban sunglasses
2016921caiyan

Paulo said...

Truth be told different banks are putting forth advance change programs for individuals all through the nation and their primary expectation is to help the mortgage holders keep their homes and assuage them from the overburden of money related emergency that is going on nowadays. usacheckcashingstore.com/chula-vista

Paulo said...

IndyMac bank advance adjustment may be performed in various diverse ways. Conceivable parkways incorporate any blend of brought down financing cost, extending the installment time frame, and fractional key self control on the advance. usapaydayloanstore.com/chicago

Robbert said...

Auto rental in Philadelphia incorporates autos of high refinement and class. Case of these are the BMW, Mercedes Benz, Rolls Royce, Land Rover, Bentley, Maybach and Cadillac among numerous others. Each of these makes an impeccable compliment particularly when contracted for a wedding. usacheckcashingstore.com/corona

Robbert said...

It's not a myth; Los Ange;es truly is the place that is known for milk and nectar and a portion of the world's wealthiest and most popular stars call this city their home. Take a comfortable around the Sunset Strip on any Saturday night and you'll unquestionably see a bundle of colorful autos cruising around including those from Lamborghini, Ferrari and Maserati. check cashing

Robbert said...

The dread of being tricked on the web keeps numerous individuals from obtaining any administration or thing regardless of the fact that the webpage is checked as being true blue. A pinch of alert is praiseworthy yet a strangely high dread of being exploited tends to harsh individual online encounters.GP Internet Offer

Home Improvement NYC said...

Ajrin Construction Inc. is a licensed New York general construction firm working as General Contractors in NYC, truly devoted to our services and remain firm until our Clients’ purposes are served to satisfaction. We feel much concerned of the value of your property, safety and security more than our profit or anything else.
Home Improvement NYC

Kanye Co Jamila said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Dot Net Training in Chennai . Nowadays Java has tons of job opportunities on various vertical industry.


or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.