We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Custom Summary Not Working in Batch Mode

Thread ID:

Created:

Updated:

Platform:

Replies:

131460 Jul 11,2017 09:52 AM UTC Jul 12,2017 04:39 PM UTC ASP.NET Core 1
loading
Tags: Grid
Zhen Liu
Asked On July 11, 2017 09:52 AM UTC

The value is always zero.

My grid code and related scripts are as below,

<ej-grid id="FlatGrid" show-summary="true" template-refresh="templateRefresh" cell-save="onCellSave">

    <e-datamanager url="/Adjustments/LineDataSource?documentId=@Model.Id" batch-url="/Adjustments/LineBatchUpdate" adaptor="UrlAdaptor" />

    <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" show-confirm-dialog="false" row-position="@(RowPosition.Bottom)" edit-mode="Batch"></e-edit-settings>

    <e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","delete" })"></e-toolbar-settings>

    <e-columns>

        <e-column field="Id" visible="false"></e-column>

        <e-column field="SKU" header-text="SKU" width="80">

            <e-edit-template create="create" read="read" write="write">

            </e-edit-template>

        </e-column>

        <e-column field="Volume" header-text="Volume" edit-type="@(EditingType.Numeric)" format="{0:N3}" numeric-edit-options="@new EditorProperties() { DecimalPlaces = 3,ShowSpinButton=false}" width="10"></e-column>

        <e-column field="UnitPrice" header-text="Price" edit-type="@(EditingType.Numeric)" format="{0:C2}" numeric-edit-options="@new EditorProperties() { DecimalPlaces = 2,ShowSpinButton=false}" width="10"></e-column>

        <e-column field="TotalPrice" header-text="Total Price" format="{0:C2}" template="{{:Volume * UnitPrice }}" allow-editing="false" text-align="Right" width="15"></e-column>

        <e-column header-Text="" width="12">

            <e-column-commands>

                <e-column-command type="delete">

                    <e-button-options size="Normal" show-rounded-corner="true" content-type="@ContentType.ImageOnly" prefix-icon="e-icon e-cancel"></e-button-options>

                </e-column-command>

            </e-column-commands>

        </e-column>

    </e-columns>

    <e-summary-rows>

        <e-summary-row title="Summary">

            <e-summary-columns>

                <e-summary-column summary-type="Sum" display-column="Volume" datamember="Volume" format="{0:N3}" />

                <e-summary-column summary-type="Custom" display-column="TotalPrice" format="{0:C2}" custom-summary-value="totalprice" />

            </e-summary-columns>

        </e-summary-row>

    </e-summary-rows>

</ej-grid>


        function onCellSave(args) {

            if (args.columnName == "Volume" || args.columnName == "UnitPrice") {

                var formatter = new Intl.NumberFormat('en-NZ', {

                    style: 'currency',

                    currency: 'NZD',

                    minimumFractionDigits: 2,

                });

                if (args.columnName == "Volume")

                    $(args.cell.closest("tr")).find(".e-templatecell").text(formatter.format(args.value * args.rowData.UnitPrice));

                else $(args.cell.closest("tr")).find(".e-templatecell").text(formatter.format(args.value * args.rowData.Volume));

            }

        } 


        function totalprice() {

            var volval, unitval;

            var totalval, sumval = [];

            var gridObj = $("#FlatGrid").ejGrid("instance");

            sumval = [];

            var data = gridObj.model.dataSource;

            for (i = 0; i < data.length; i++) {

                volval = data[i].Volume;

                unitval = data[i].UnitPrice;

                totalval = volval * unitval;

                sumval.push(totalval);

            }

            var result = ej.sum(sumval);

            return (result);

        }

        function templateRefresh(args) {
            if (args.cell.innerHTML.split("$").length == 1)
                args.cell.innerHTML = "$" + parseFloat(args.cell.innerHTML).toFixed(2);
        }

        function create() {
            return $("<input>");
        }

        function write(args) {
            var proddata =  @Html.Raw(Json.Serialize(ViewBag.productcodes));
            args.element.ejAutocomplete({ width: "100%", dataSource: proddata, fields: { text: "value" }, enableDistinct: true, enableAutoFill : true, value: args.rowdata !== undefined ? args.rowdata["SKU"] : "", select: "onautoselect" });
        }

        function read(args) {
            args.ejAutocomplete('suggestionList').css('display', 'none');
            return args.ejAutocomplete("getValue");
        }

 


Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On July 12, 2017 04:39 PM UTC

Hi Zhen, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and  we have suspected that you are facing this problem while using “URL Adaptor with summary”. When you bind remoteData to the Grid, Summary Row must be handled by returning summary column datasource into the aggregate property of result object. 

Please refer to the code example:- 

Clientside:- 
<ej-grid id="FlatGrid" allow-paging="true" show-summary="true"> 
<e-datamanager url="/Home/DataSource" insert-url="/Home/CellEditInsert" update-url="/Home/CellEditUpdate" remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor"></e-datamanager> 
            <e-summary-rows> 
                  <e-summary-row title="Currency"> 
                      <e-summary-columns> 
                          <e-summary-column summary-type="Custom" custom-summary-value="currency" format="{0:C2}" display-column="Freight" /> 
                      </e-summary-columns> 
                  </e-summary-row> 
              </e-summary-rows>            
                <e-columns> 
                <e-column field="OrderID" header-text="Order ID" width="80" text-align="Right"></e-column> 
                <e-column field="EmployeeID" header-text="Employee ID" text-align="Right" width="80"></e-column> 
                 
            </e-columns> 
   </ej-grid> 
 
Serverside:- 
   public partial class GridController : Controller 
        { 
            public ActionResult GridFeatures() 
            { 
 
                ViewBag.dataSource = OrderRepository.GetAllRecords().ToList(); 
                return View(); 
            } 
 
            public ActionResult DataSource([FromBody]DataManager dm) 
            { 
                IEnumerable DataSource = OrderRepository.GetAllRecords(); 
                DataOperations ds = new DataOperations(); 
                List<string> str = new List<string>(); 
                if (dm.Aggregates != null) 
                { 
                    for (var i = 0; i < dm.Aggregates.Count; i++) 
                        str.Add(dm.Aggregates[i].Field); 
                    result.aggregate = ds.PerformSelect(DataSource, str); 
                } 
 
                DataSource = ds.PerformSkip(DataSource, dm.Skip); 
                result.result = ds.PerformTake(DataSource, dm.Take); 
                result.count = DataSource.AsQueryable().Count(); 
                return Json(result, JsonRequestBehavior.AllowGet); 
 
            } 
 
            public class DataResult 
            { 
                public IEnumerable result { get; set; } 
                public int count { get; set; } 
                public IEnumerable aggregate { get; set; } 
                public IEnumerable groupDs { get; set; } 
            } 
 
        } 
   

Refer to the documentation on MVC:- 


After following the above steps, still facing issue could you please share us the following details with us. 

1. Grid code example( both in server and client side) 

2. Screenshot/Video to replicate the issue. 

3.  An issue reproducing sample if possible or sample hosted link. 
 
4. Essential studio version and browser details. 

The provided information will help us to analyze and provide you the solution as early as possible. 
 
Regards, 
 
Farveen sulthana T 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;