Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Custom Summary forcing ShowSummariesButtons to true
posted

I am using the summary row on my WebDataGrid to show totals for financial columns.  This is working very nicely, with the summary info added programmatically to the appropriate columns, and ShowSummariesButton="false" in the html source.  However, I now want to add a label in the summary row in the first column to show "Totals:" or some variant of that.

I've gone through the exercise of programmatically adding a custom summary to the first column so that it will show the text I want it to.  That is working fine.  However, the summary button icon is showing up in the header of that column with the custom summary, even though ShowSummariesButton="false" at the grid level.

Any idea why that summary button would be showing up in the header, overriding my choice in the ShowSummariesButton attribute?  I've looked through the ColumnSummaryInfo, Summary, SummaryRowSetting and SummarySetting objects and in none of them do I see the ability to affect the summary button.

Is there another way to update the text in a summary cell?  This seems like something that you'd expect there to be an event handler for.  Adding a custom summary just for this seems like serious overkill.

Thanks for your help,

Phil

Parents Reply
  • 240
    Offline posted in reply to Phillip Peters

    Nikifor,

    My situation seems a little different than the sample you put together.  Here is my rendered grid:

    The circled words in the summary row are determine programmatically and need to be inserted into that columns summary cell.  So I am not able to do anything in markup.  Here is my Behaviors tag:

    <Behaviors>
        <ig:SummaryRow ShowSummariesButtons="false" FormatString="{1}" EmptyFooterText="" CompactRendering="On" SummariesCssClass="headerGrid">
            <ColumnSummaries>
            </ColumnSummaries>
        </ig:SummaryRow>
        <ig:ColumnFixing AutoAdjustCells="true" ShowRightSeparator="true" ShowLeftSeparator="true" ShowFixButtons="false">
            <ColumnSettings>
            </ColumnSettings>
        </ig:ColumnFixing>
    </Behaviors>

    You'll note that I have some extra attributes specified, such as the FormatString and CompactRendering="On".

    Then via code I build the columns just before binding the grid. For that first column I do the following extra work, besides adding the column to the columns collection:

    SummaryRowSetting oTopCategoryNameRowSetting = new SummaryRowSetting(wdgPlanningAggregate, FieldKey);
    SummarySetting oTopCategoryNameSetting = new SummarySetting();
    oTopCategoryNameSetting.SummaryType = SummaryType.Custom;
    oTopCategoryNameSetting.CustomSummaryName = "TopCategoryName";
    oTopCategoryNameSetting.FormatString = ExpenseCategory;
    oTopCategoryNameSetting.CssClass = "headerGrid";
    oTopCategoryNameSetting.ShowOptionInDropDown = false;
    oTopCategoryNameRowSetting.SummarySettings.Add(oTopCategoryNameSetting);
    wdgPlanningAggregate.Behaviors.SummaryRow.ColumnSettings.Add(oTopCategoryNameRowSetting);
    oSummaryInfo = new ColumnSummaryInfo(); oSummaryInfo.ColumnKey = field.Key; Summary oSummary = new Summary(); oSummary.SummaryType = SummaryType.Custom; oSummary.CustomSummaryName = "TopCategoryName"; oSummaryInfo.Summaries.Add(oSummary);
    grid.Behaviors.SummaryRow.ColumnSummaries.Add(oSummaryInfo);

    This code defines the custom summary and puts it in the ColumnSettings collection, and then adds the custom summary for that first field into the ColumnSummaries collection, so that it is "on" for that column.

    In your example you were using SummaryType of Sum, whereas I need to use Custom.  I've tried changing that to Count, which is the only other valid type for a string column.  It still caused the summary button to show as you see in the image above.

    Could you update your sample to work in this similar fashion and see if it causes the summary button to show up?

    Thanks,

    Phil

Children