Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've developed a SharePoint WebPart but am having trouble editing it in the SharePoint Designer. My WebPart is supposed to be a thin wrapper around a DevExpress Chart which exposes all the settings in SharePoint designer. My code looks like this (note that the Chart.acsx.g.cs has a protected member chartControl:

  [ControlBuilder(typeof(ChartControlBuilder))]
public partial class Chart : Microsoft.SharePoint.WebPartPages.WebPart, IChartView, IWebEditable
{
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public WebChartControl ChartControl
    {
        get { return this.chartControl; }
        set { this.chartControl = value; }
    }

    protected override void AddParsedSubObject(object obj)
    {
        if (obj != null)
            Trace.WriteLine(obj.GetType());

        base.AddParsedSubObject(obj);
    }

Where the ChartControlBuilder does the following:

 public class ChartControlBuilder : ControlBuilder
{
    public override Type GetChildControlType(string tagName, System.Collections.IDictionary attribs)
    {
        if (tagName == "ChartControl")
            return typeof(WebChartControl);

        Type type = base.GetChildControlType(tagName, attribs);
        return type;
    }
}

This gives me the following output in SharePoint Designer... I decided to make a simple change, modifying the width of the Width of the ChartControl:

<WpNs0:Chart runat="server" AllowEdit="True" AllowConnect="True" ConnectionID="00000000-0000-0000-0000-000000000000" Title="Chart" ConnectionString="Data Source=esx-sharepoint;Initial Catalog=Test;Uid=User1;Pwd=MyPassword;" Dir="Default" IsIncluded="True" IsVisible="True" CatalogIconImageUrl="/_layouts/images/WebParts/ChartIcon.png" AllowMinimize="True" AllowHide="True" ExportControlledProperties="True" ZoneID="LeftColumn" ID="g_5ea391cf_215a_48bc_bd24_267d8ef5d9d0" FrameState="Normal" SelectQuery="select top 20        TH.TH_TNM_Threat_Name,        TH.TH_TSS_Threat_SOCScore AS [SOC Score] from lTH_parent_TH_to T1 inner join lTH_Threat THP on THP.TH_ID=T1.TH_ID_parent inner join lTH_Threat TH on TH.TH_ID=T1.TH_ID_to where        THP.TH_TNM_Threat_Name='Global Threat' order by TH.TH_TSS_Threat_SOCScore DESC" ExportMode="All" AllowRemove="True" SuppressWebPartChrome="False" DetailLink="" HelpLink="" MissingAssembly="Cannot import this Web Part." PartImageSmall="/_layouts/images/WebParts/ChartIcon.png" TitleIconImageUrl="/_layouts/images/WebParts/ChartIcon.png" HelpMode="Modeless" FrameType="Default" AllowZoneChange="True" PartOrder="2" Description="A web part used to display a Chart" PartImageLarge="/_layouts/images/WebParts/ChartIcon.png" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{5EA391CF-215A-48BC-BD24-267D8EF5D9D0}" WebPart="true" Height="" Width="">
<ChartControl Width="300px" Height="200px" Theme="BlackGlass" EnableTheming="True" ID="chartControl"><DiagramSerializable>
<cc1:XYDiagram>
<AxisX VisibleInPanesSerializable="-1">
<Range SideMarginsEnabled="True"></Range>
</AxisX>

<AxisY VisibleInPanesSerializable="-1">
<Range SideMarginsEnabled="True"></Range>
</AxisY>
</cc1:XYDiagram>
</DiagramSerializable>

<FillStyle><OptionsSerializable>
<cc1:SolidFillOptions></cc1:SolidFillOptions>
</OptionsSerializable>
</FillStyle>
<SeriesSerializable>
<cc1:Series Name="Series 1"><ViewSerializable>
<cc1:SideBySideBarSeriesView></cc1:SideBySideBarSeriesView>
</ViewSerializable>
<LabelSerializable>
<cc1:SideBySideBarSeriesLabel LineVisible="True">
<FillStyle><OptionsSerializable>
<cc1:SolidFillOptions></cc1:SolidFillOptions>
</OptionsSerializable>
</FillStyle>
<PointOptionsSerializable>
<cc1:PointOptions></cc1:PointOptions>
</PointOptionsSerializable>
</cc1:SideBySideBarSeriesLabel>
</LabelSerializable>
<LegendPointOptionsSerializable>
<cc1:PointOptions></cc1:PointOptions>
</LegendPointOptionsSerializable>
</cc1:Series>
</SeriesSerializable>

<SeriesTemplate><ViewSerializable>
<cc1:SideBySideBarSeriesView></cc1:SideBySideBarSeriesView>
</ViewSerializable>
<LabelSerializable>
<cc1:SideBySideBarSeriesLabel LineVisible="True">
<FillStyle><OptionsSerializable>
<cc1:SolidFillOptions></cc1:SolidFillOptions>
</OptionsSerializable>
</FillStyle>
<PointOptionsSerializable>
<cc1:PointOptions></cc1:PointOptions>
</PointOptionsSerializable>
</cc1:SideBySideBarSeriesLabel>
</LabelSerializable>
<LegendPointOptionsSerializable>
<cc1:PointOptions></cc1:PointOptions>
</LegendPointOptionsSerializable>
</SeriesTemplate>

<CrosshairOptions><CommonLabelPositionSerializable>
<cc1:CrosshairMousePosition></cc1:CrosshairMousePosition>
</CommonLabelPositionSerializable>
</CrosshairOptions>

<ToolTipOptions><ToolTipPositionSerializable>
<cc1:ToolTipMousePosition></cc1:ToolTipMousePosition>
</ToolTipPositionSerializable>
</ToolTipOptions>
</ChartControl>
</WpNs0:Chart>

If I modify the width of the ChartControl I notice that AddParsedSubObject gets called a number of times and it seems to have a WebChartControl (width 800px yay!) and another one (which is the this.chartControl instance with a width if 300px). I don't understand why I've got these 2 instances being added to this.Controls (this is what the AddParsedSubObject does in the base) in the first place.

When I preview the page from SharePoint designer, or the web I notice that there is now only 1 WebChartControl added in AddParsedSubObject with the 300px default width. I don't understand what's happening, could someone help get me going in the right direction? Things I've looked at so far:

  • Ensuring I'm checking files in after changing them in SharePoint Designer.
  • Editing files in Advanced Mode.
  • I searched for but couldn't find the ddwrt:ghost="hide" string in the ChartTest.aspx page in SharePoint Designer.

Thanks for your help.

EDIT

I've tried adding another property onto the Chart (SelectQuery) which is included in the ASPX output in the designer as an Attribute on my webpart. I've noticed that I am successfully able to modify that attribute and the chart will update on a refresh or preview. It only seems to be if I modify the child control that things don't update correctly.

share|improve this question
add comment

1 Answer

Not sure if this would help, but it may be another solution for you to try. save your webpart and install it in SharePoint. Then in SP designer create a web part zone with a table in it. Add your webpart inside of the table from SP designer. This should constrict the WP to the size of the table.

share|improve this answer
    
I've used size as a trivial example, in reality there are a whole range of properties I may wish to change (palette, connection string, axis label position etc. etc). Your answer may workaround the particular issue I have here in my example but is not the sort of answer I'm after. –  Ian Oct 11 '12 at 7:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.