Hello
how to display a currency Value in an iggrid without showing the decimal value if the decimal doesn't contain any fraction. in an MVC application.
Best Regards
Pradeep
Hello Pradeep,
You can try our column formatter functionality in order to achieve this. Using this approach you can just specify a function for the formatter property of your decimal column, and in this function you can format the value the way you want. For additional reference on this matter you could check:
http://ko.infragistics.com/products/jquery/sample/grid/column-formatter
If you need any additional assistance on this please let me know.
hi Elena,
Thanks for your reply, i used the currency formatter as it is given in the example, but the masking is not displaying for the currency filed, and also I have used a string field which contains a break line "<br />" . if i am using the "template" option then the "<br />" is displaying instead of it is breaking the lines.
Thanks and Best Regards
I have been looking into the issue that you are describing still I am not sure that I understand your scenario. Would you please provide me with the code that you use for creating the igGrid columns, also did you use the rowTemplating functionality of the igGrid?
Thanks in advance.
Hello Elena,
Thanks for your reply. Here is the code for generating the grid.
Here I have Address and purchase price column along with that i have some more column.
i don't want to show decimal value and also i want to show masking for currency.
if i Used template:$${"PurchasePrice"} then i am able to display as per my requirement but in the Address field i am not getting any new line means its displaying like this - "ADD1,Add2 <br /> City, State 900015"
function ShowPropertyGrid(data){ $.ig.loader({ scriptPath: "~/Scripts/Common/", cssPath: "~/Scripts/InfragisticsjQueryMVC/Common/CSS/structure/", resources: "igGrid.Summaries,igEditors,igGrid.Selection,igGrid.Resizing" }); $.ig.loader(function () { $("#idh4").hide(); $("#gridProperty_container").empty(); try{ $("#btnUpdate").igButton({ labelText: "Format Summaries", click: function (event) { $("#gridProperty").igGridSummaries("option", "resultTemplate", $("#resultTemplate").val()); $("#gridProperty").igGridSummaries("option", "isGridFormatter", $("#isGridFormatter").is(":checked")); $("#gridProperty").igGridSummaries("option", "defaultDecimalDisplay", $("#defaultDecimalDisplay").val()); } }) } catch(ex) { } $("#decimalDisplayRow").hide(); $("#isGridFormatter").bind({ change: function (event) { if ($(this).is(":checked")) { $("#decimalDisplayRow").hide(); } else { $("#decimalDisplayRow").show(); } } }) try{ $("#defaultDecimalDisplay").igNumericEditor({ width: 50, minValue: 0, maxValue: 10, nullText: "default" }); } catch(ex) { } $("#gridProperty").igGrid({ height: 200, columns: [ { headerText: "FKPropertyID", key: "FKPropertyID", dataType: "number",hidden:true}, { headerText: "Address", key: "Address", dataType: "string",width:"190px",format:"{0}",formatter:formatAddress}, { headerText: "Transaction", key: "TransactionType", dataType: "string",width:"120px" }, { headerText: "Property", key: "PropertyName", dataType: "string",width:"130px" }, { headerText: "Purchase Price", key: "PurchasePrice", dataType: "number" ,format: "currency" , width:"130px" },
//For this purchase price i don't want to show decimal value and also i want to show masking for currency,
// if i Used template:$${"PurchasePrice"} then i am able to display as per my requirement but in the Address field i am not getting any new line
{ headerText: "Purchase Date", key: "Pdate", dataType: "string",format:"MM/dd/yyyy" ,width:"130px"}, { headerText: "Existing Debt", key: "ExistingLoan", dataType: "string" ,format: "{$}{#}", width:"130px"}, { headerText: "Value", key: "PropertyValue", dataType: "number", width:"140px" ,format: "currency" }, { headerText: "Valuation Method", key: "ValuationMethod", dataType: "string" ,width:"140px"}, { headerText: "Loan Amount", key: "PropertyLoanAmount", dataType: "number" ,format: "currency" ,width:"120px"},//,formatter:formatCurrency ], autoGenerateColumns: false, //ClientDataSourceType(ClientDataSourceType.JSON) dataType: "JSON", dataSource: data.Records, responseDataKey: "Records", features: [ { name: "Summaries", showHeaderButton: false, showDropDownButton: false, compactRenderingMode: false, columnSettings: [ { columnKey: "PropertyValue", allowSummaries: true, summaryOperands: [ { "rowDisplayLabel": "Sum", "type": "SUM", "active": true } ] }, { columnKey: "PropertyLoanAmount", allowSummaries: true, summaryOperands: [ { "rowDisplayLabel": "Sum", "type": "SUM", "active": true,format:"currency" } ] }, {columnKey:"FKPropertyID",allowSummaries:false}, {columnKey:"PropertyName",allowSummaries:false}, { columnKey: "Address", allowSummaries: false }, { columnKey: "TransactionType", allowSummaries: false }, { columnKey: "PurchasePrice", allowSummaries: false }, { columnKey: "PurchaseDate", allowSummaries: false }, { columnKey: "Pdate", allowSummaries: false }, { columnKey: "ExistingLoan", allowSummaries: false }, { columnKey: "ValuationMethod", allowSummaries: false } ] }, { name: 'Selection', mode: 'row' }, { name : 'Resizing' } ], }); $("#gridProperty tr").dblclick(function (e) { var row = $('#gridProperty').igGridSelection('selectedRow'); var dataview = $('#gridProperty').data('igGrid').dataSource.dataView(); var cellValue = dataview[row.index]["FKPropertyID"]; _selectedPropertyId=cellValue; setgrid=1; }); $('#gridProperty_summaries_footer_row_text_container_sum_PropertyValue').remove("Sum= "); $('#gridProperty_summaries_footer_row_text_container_sum_PropertyValue').autoNumeric({ aSep: ',', aDec: '.',aSign: '$', vMax: '99999999999999.99',mDec:0 }); }); igloader=$.ig; }
Thanks and best regards
Thank you for your snippets. I tested the issue that you described by modifying this sample:
I placed a couple of <br> tags in the formatter of the last column still on my side everything seems to be formatted as expected. Would you please check the attached sample and modify it in order to represent the issue that you mentioned so I can investigate this further.
I was just wondering did you have a chance to try my sample. If you still need any assistance on the matter, please do not hesitate to ask.
I have tried the example you have suggested and modify the formatter for currency as per my requirement. like this
var checkthis = "$"+ val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",").toString();
and its working for me.
Thanks for your help.
Best regards