Hi Dr,
Thanks for contacting Syncfusion Support.
Query 1: I have tried with "cellSaved" event and it's working but it seems like overhead to me.
When perform Editing, the changes affected only on the edited cells and the content will be refreshed after the batch save. So, refresh the compute column when edit the cell each time using cellSave event of Grid like as you said.
Query 2: are there some specifics for unbound columns to be set-up.
Please provide the following information regarding your query?
1. What did you meant the unbound column set-up?
2. Did you mean recalculate the compute field while editing using command column?
Query 3 & Query 4?
We are validating your requirement, we will get back to you with further information on November 18, 2015.
Regards,
Saravanan A.
Hi Kivito,
Query 1: I was looking expressions column but unfortunately it is not clear how to use it within lightswitch.
We can render the template column two ways in LightSwitch Html.
1. Render the template in the column itself.
We can render the column template in the Grid column itself using template property of Grid column. Please refer to the code example.
columns: [ . . . { headerText: "ExpressionCell", width: 75, template: "<span>{{:EmployeeID * Freight}}</span>"} ] |
2. Render the template using TemplateID property
Render the JSRender template for the column using TemplateID property of Grid Column. Please refer to the code example and online documentation link.
[default.html] <script type='text/jsrender' id='expTemp'> <span>{{:EmployeeID * Freight}}</span> </script> columns: [ //TemplateID should be id of the JSRender element { headerText: "ExpressionCell", width: 75, template: true, templateID: "#expTemp"} ] |
http://help.syncfusion.com/js/api/ejgrid#members:columns-templateid
Query 2: Refresh the Custom Summary
We have refreshed the custom Summary using “cellSave” event of Grid and recomputed the expression cell (Template column). Please refer to the code example.
cellSave: function (args) { var calc=0; if (args.columnName == "EmployeeID") calc = args.value + parseFloat(args.rowData.Freight); else if (args.columnName == "Freight") { calc = parseFloat(args.value) + parseFloat(args.rowData.EmployeeID); var extra = parseFloat(args.value) - parseFloat(args.previousValue); //To recompute the template cell args.cell.closest("tr").find(".e-templatecell span")[0].innerHTML = calc.toString(); //To Refresh Custom Summary var summary = ($("td.e-summaryrow")[args.cell.index()].innerHTML).replace(/[$,]/g, "") var summaryval = (parseFloat(summary) + extra).toFixed(2); $("td.e-summaryrow")[args.cell.index()].innerHTML = "$" + summaryval;//assigning the innerHTML of the summaryrow with updated value } }, |
We have created a sample that you can download from the below link.
http://www.syncfusion.com/downloads/support/forum/121162/ze/F121162-709422308
Regards,
Saravanan A.
Hi Kivito,
Please ignore the previous update.
Query 1: I was looking expressions column but unfortunately it is not clear how to use it within lightswitch.
We can render the template column two ways in LightSwitch Html.
1. Render the template in the column itself.
We can render the column template in the Grid column itself using template property of Grid column. Please refer to the code example.
columns: [ . . . { headerText: "ExpressionCell", width: 75, template: "<span>{{:EmployeeID * Freight}}</span>"} ] |
2. Render the template using TemplateID property
Render the JSRender template for the column using TemplateID property of Grid Column. Please refer to the code example and online documentation link.
[default.html] <script type='text/jsrender' id='expTemp'> <span>{{:EmployeeID * Freight}}</span> </script> columns: [ //TemplateID should be id of the JSRender element { headerText: "ExpressionCell", width: 75, template: true, templateID: "#expTemp"} ] |
http://help.syncfusion.com/js/api/ejgrid#members:columns-templateid
Query 2: Refresh the Custom Summary
We have refreshed the custom Summary using “cellSave” event of Grid and recomputed the expression cell (Template column). Please refer to the code example.
cellSave: function (args) { var calc=0; if (args.columnName == "EmployeeID") calc = args.value + parseFloat(args.rowData.Freight); else if (args.columnName == "Freight") { calc = parseFloat(args.value) + parseFloat(args.rowData.EmployeeID); var extra = parseFloat(args.value) - parseFloat(args.previousValue); //To recompute the template cell args.cell.closest("tr").find(".e-templatecell span")[0].innerHTML = calc.toString(); //To Refresh Custom Summary var summary = ($("td.e-summaryrow")[args.cell.index()].innerHTML).replace(/[$,]/g, "") var summaryval = (parseFloat(summary) + extra).toFixed(2); $("td.e-summaryrow")[args.cell.index()].innerHTML = "$" + summaryval;//assigning the innerHTML of the summaryrow with updated value } }, |
We have created a sample that you can download from the below link.
http://www.syncfusion.com/downloads/support/forum/121162/ze/F121162913076687
Regards,
Saravanan A.
Hi Kivito,
Query 1: How could I force expression template to add numbers instead of concatenating as strings?
To add the numbers using template column, the numbers should not be string. If the numbers are string, it will concatenate instead of adding.
We have achieved your requirement using “Jquery helpers” which parses the string to float, adds and then return to the template column. Please refer to the below code example.
<script type='text/jsrender' id='expTemp'> {{>~ Adding (EmployeeID, Freight)}} </script> <script type="text/javascript"> $.views.helpers({ Adding: function (args1, args2) { sum = args1 + parseFloat(args2); return sum; } });
</script> itemTemplate.ejGrid( { dataSource: data, . . . columns: [ . . . { headerText: "ExpressionCell", width: 75, template: true, templateID: "#expTemp" } ] }); } |
Query 2 : Can I manually force grid to render in phone mode at resolution more then 321px (ie 400px)?
Yes, you can render the Grid in phone mode at resolution more than 321px through overwriting the media query css in “ejgrid.responsive.css” which is located in following location and refer to the code to overwrite the css.
{programfilesfolder}\Syncfusion\Essential Studio\{Version}\JavaScript\assets-src\css\web\responsive-css\ejgrid.responsive.
/*overwrite from 320px to 400px*/ @media (max-width :400px) { .e-grid.e-responsive > [id*='Dlg_wrapper'] { width: 130px !important; } /*When greater than the phone mode(changed from 321px to 401px )*/ @media (min-width: 401px) and (max-width:479px) { .e-grid .e-table-priority-6, .e-grid .e-table-priority-5, .e-grid .e-table-priority-4, .e-grid .e-table-priority-3, .e-grid .e-table-priority-2 { display: none !important; } } |
Regards,
Saravanan A.
Hi Kivito,
Thanks for your update.
We are happy that the provided information helped you.
Regards,
Saravanan A.