BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<ej-grid id="FlatGrid" datasource="ViewBag.data" allow-paging="true" show-summary="true" action-complete="complete">
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="@(EditMode.Normal)"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","delete","update","cancel" })"></e-toolbar-settings>
<e-columns>
...
<e-column field="EmployeeID" header-text="Employee ID" text-align="Right" width="75"></e-column>
<e-column field="Freight" header-text="Freight" format="{0:C}" width="75"></e-column>
<e-column field="Sum" header-text="Sum" template="<span>{{:EmployeeID + Freight }}</span>" allow-editing="false" text-align="Right" width="75"></e-column>
</e-columns>
<e-summary-rows>
<e-summary-row title="Total sum">
<e-summary-columns>
<e-summary-column summary-type="Custom" display-column="Sum" custom-summary-value= "currency" />
</e-summary-columns>
</e-summary-row>
</e-summary-rows>
</ej-grid>
<script>
var frightval, empval;
var totalval, sumval = [];
function currency() {
var gridObj = $("#FlatGrid").ejGrid("instance");
sumval = [];
for (i = 0; i < gridObj.model.dataSource.length; i++) {
frightval = gridObj.model.dataSource[i].Freight;
empval = gridObj.model.dataSource[i].EmployeeID;
totalval = frightval + empval;
sumval.push(totalval);
}
var result = ej.sum(sumval);
return (result); //it will return the total summary value for the template column.
}
function complete (args) {
if (args.requestType == "beginedit") { // when editing the value in two columns we have changed the value at run time for the total value column(i.e template column)
row = args.row;
$(args.row.find("input")).bind('keypress keyup', function (e) {
if(e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode == 8) { //you can prevent as per the user need where key code 37 is left arrow and 39 is right arrow.
...
var value = columnA + columnB;
row.find(".e-templatecell").text(value);
}
});
}
}
</script> |
<ej-grid id="FlatGrid" show-summary="true" action-complete="complete" begin-edit="beginedit">
<e-datamanager json="(IEnumerable<object>)ViewBag.datasource" update-url="/Adjustments/LineUpdate?adjustmentId=@Model.Id" insert-url="/Adjustments/LineInsert?adjustmentId=@Model.Id" remove-url="/Adjustments/LineDelete?adjustmentId=@Model.Id" adaptor="remoteSaveAdaptor" />
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="@(EditMode.Normal)"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","delete","update","cancel" })"></e-toolbar-settings>
<e-columns>
<e-column field="Id" is-primary-key="true" visible="false"></e-column>
<e-column field="AdjustmentId" visible="false"></e-column>
<e-column field="CurrencyId" visible="false"></e-column>
<e-column field="ProductCode" datasource="(IEnumerable<object>)ViewBag.productcodes" edit-type="@(EditingType.Dropdown)" header-text="Product" width="80"></e-column>
<e-column field="Piece" header-text="Piece" width="10"></e-column>
<e-column field="Volume" header-text="Volume" width="10"></e-column>
<e-column field="Weight" header-text="Weight" width="10"></e-column>
<e-column field="UnitCost" header-text="Price" format="{0:C2}" width="10"></e-column>
<e-column field="Total" header-text="Total Price" template="<span>{{:Volume * UnitCost }}</span>" format="{0:C2}" allow-editing="false" text-align="Right" width="10"></e-column>
</e-columns>
<e-summary-rows>
<e-summary-row title="Total">
<e-summary-columns>
<e-summary-column summary-type="Custom" display-column="Total" format="{0:C2}" custom-summary-value="currency" />
</e-summary-columns>
</e-summary-row>
</e-summary-rows>
</ej-grid>
...
function currency() {
var gridObj = $("#FlatGrid").ejGrid("instance");
sumval = [];
var data = this.model.dataSource.dataSource.json; //helps to retrieve whole data when using remoteSaveAdaptor in grid.
for (i = 0; i < data.length; i++) {
frightval = data[i].Freight;
empval = data[i].EmployeeID;
totalval = frightval + empval;
sumval.push(totalval);
}
var result = ej.sum(sumval);
return (result);
}
... |