Custom Summary Item wont work after LoadLayout

4 posts, 0 answers
  1. mehdi
    mehdi avatar
    3 posts
    Member since:
    May 2015

    Posted 14 Nov 2017 Link to this post

    Hello,

    I created a CustomSummaryItem and it work correctly when I add it to summary row with code, but if I save GridView layout and load it the custom summary wont function 

     

    this is my CustomSummaryItem: 

    public class CustomSummaryItem : GridViewSummaryItem
        {
            public CustomSummaryItem(string name,string sourceColumn)
                : base(name, "{0}",GridAggregateFunction.Sum)
            {
                SourceColumn = sourceColumn;
            }
            public string SourceColumn { get; set; }
            public override object Evaluate(IHierarchicalRow row)
            {
               
                var sum = row.ChildRows.Sum(childRow => (childRow.Cells[this.SourceColumn]?.Value).ToDouble());
                var time = TimeSpan.FromMilliseconds(sum).ToString();
                return time;
            }
        }

     

  2. mehdi
    mehdi avatar
    3 posts
    Member since:
    May 2015

    Posted 14 Nov 2017 in reply to mehdi Link to this post

    And this is my layout:

     

    <RadGridView Text="gvItems" Cursor="Default" TabIndex="0">
      <MasterTemplate AllowDragToGroup="False" AllowDeleteRow="False" AllowAddNewRow="False">
        <SummaryRowsBottom>
          <Telerik.WinControls.UI.GridViewSummaryRowItem>
            <YalitPerson.SalariesForms.CustomSummaryItem SourceColumn="WorkMili" AggregateExpression="" Aggregate="Sum" Name="WorkMiliView" FormatString="{0}" />
            <YalitPerson.SalariesForms.CustomSummaryItem SourceColumn="OvertimeMili" AggregateExpression="" Aggregate="Sum" Name="OvertimeMiliView" FormatString="{0}" />
            <YalitPerson.SalariesForms.CustomSummaryItem SourceColumn="FractionMili" AggregateExpression="" Aggregate="Sum" Name="FractionMiliView" FormatString="{0}" />
            <YalitPerson.SalariesForms.CustomSummaryItem SourceColumn="VacationMili" AggregateExpression="" Aggregate="Sum" Name="VacationMiliView" FormatString="{0}" />
            <Telerik.WinControls.UI.GridViewSummaryItem AggregateExpression="" Aggregate="Sum" Name="OvertimeDays" FormatString="{0}" />
            <Telerik.WinControls.UI.GridViewSummaryItem AggregateExpression="" Aggregate="Sum" Name="FractionDays" FormatString="{0}" />
            <Telerik.WinControls.UI.GridViewSummaryItem AggregateExpression="" Aggregate="Sum" Name="VacationDays" FormatString="{0}" />
          </Telerik.WinControls.UI.GridViewSummaryRowItem>
        </SummaryRowsBottom>
        <Columns>
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Int32" FieldName="Id" Name="Id" IsAutoGenerated="True" IsVisible="True" HeaderText="کد" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="89" FieldName="Title" Name="Title" IsAutoGenerated="True" IsVisible="True" HeaderText="عنوان" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDateTimeColumn Width="132" FieldName="CreationDate" Name="CreationDate" IsAutoGenerated="True" IsVisible="True" HeaderText="تاریخ ساخت" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDateTimeColumn Width="132" FieldName="EffectiveDate" Name="EffectiveDate" IsAutoGenerated="True" IsVisible="True" HeaderText="تاریخ تاثیر" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="64" FieldName="WorkMiliView" Name="WorkMiliView" IsAutoGenerated="True" IsVisible="True" HeaderText="ساعات کاری" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="77" FieldName="OvertimeMiliView" Name="OvertimeMiliView" IsAutoGenerated="True" IsVisible="True" HeaderText="اضافه‌کاری(س)" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="78" FieldName="OvertimeDays" Name="OvertimeDays" IsAutoGenerated="True" IsVisible="True" HeaderText="اضافه‌کاری(روز)" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="59" FieldName="FractionMiliView" Name="FractionMiliView" IsAutoGenerated="True" IsVisible="True" HeaderText="کسرکار(س)" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="60" FieldName="FractionDays" Name="FractionDays" IsAutoGenerated="True" IsVisible="True" HeaderText="کسرکار(روز)" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="64" FieldName="VacationMiliView" Name="VacationMiliView" IsAutoGenerated="True" IsVisible="True" HeaderText="مرخصی(س)" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="65" FieldName="VacationDays" Name="VacationDays" IsAutoGenerated="True" IsVisible="True" HeaderText="مرخصی(روز)" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="177" FieldName="Description" Name="Description" IsAutoGenerated="True" IsVisible="True" HeaderText="توضیحات" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="64" FieldName="WorkHours" Name="WorkHours" IsAutoGenerated="True" IsVisible="False" HeaderText="WorkHours" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="84" FieldName="OvertimeHours" Name="OvertimeHours" IsAutoGenerated="True" IsVisible="False" HeaderText="OvertimeHours" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="78" FieldName="FractionHours" Name="FractionHours" IsAutoGenerated="True" IsVisible="False" HeaderText="FractionHours" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="87" FieldName="SalarieHeaderId" Name="SalarieHeaderId" IsAutoGenerated="True" IsVisible="False" HeaderText="SalarieHeaderId" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn Width="81" FieldName="VacationHours" Name="VacationHours" IsAutoGenerated="True" IsVisible="False" HeaderText="VacationHours" TextAlignment="MiddleCenter" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="53" FieldName="WorkMili" Name="WorkMili" IsAutoGenerated="True" IsVisible="False" HeaderText="WorkMili" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="73" FieldName="OvertimeMili" Name="OvertimeMili" IsAutoGenerated="True" IsVisible="False" HeaderText="OvertimeMili" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="67" FieldName="FractionMili" Name="FractionMili" IsAutoGenerated="True" IsVisible="False" HeaderText="FractionMili" />
          <Telerik.WinControls.UI.GridViewDecimalColumn TextAlignment="MiddleCenter" DataType="System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Width="69" FieldName="VacationMili" Name="VacationMili" IsAutoGenerated="True" IsVisible="False" HeaderText="VacationMili" />
          <Telerik.WinControls.UI.GridViewTextBoxColumn DataType="YalitPerson.Models.SalarieHeader" FieldName="SalarieHeader" Name="SalarieHeader" IsAutoGenerated="True" IsVisible="False" ReadOnly="True" HeaderText="SalarieHeader" TextAlignment="MiddleCenter" />
        </Columns>
        <ViewDefinition xsi:type="Telerik.WinControls.UI.TableViewDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </MasterTemplate>
    </RadGridView>

     

  3. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4079 posts

    Posted 15 Nov 2017 Link to this post

    Hello, Mehdi,

    Thank you for writing.  

    In order to save the custom summary row in the layout, it is necessary to have a parameterless constructor for the custom GridViewSummaryItem. In addition, the GridViewSummaryItem class must be defined outside the form's class. I have attached a sample project for your reference.

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. mehdi
    mehdi avatar
    3 posts
    Member since:
    May 2015

    Posted 02 Dec 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Tanks Dess

    it works correctly 

Back to Top