jQWidgets Forums
Forum Replies Created
-
Author
-
April 10, 2015 at 2:46 pm in reply to: Formatting a number type value in a cell Formatting a number type value in a cell #69769
Hi Peter,
The value is not 1. As you can see, the value is 1.0 at least. How is it treated as 1?
Is it correct?
What did I misunderstand?
Regards,
Scott KangApril 10, 2015 at 1:56 pm in reply to: Formatting a number type value in a cell Formatting a number type value in a cell #69765Hi Peter Stoev,
I attached simple html page to show my current issue. When I double clicked a row, the value of Amount is set in the text field below the DataTable.
The result still shows 1 not 1.00.
What may be wrong?========================================================================================
<!DOCTYPE html>
<head>
<link rel=”stylesheet” href=”jqwidgets-ver3/jqwidgets/styles/jqx.base.css” type=”text/css”/>
<link rel=”stylesheet” href=”jqwidgets-ver3/jqwidgets/styles/jqx.metro.css” type=”text/css”/>
</head>
<body>
<p></p>
<table width=”100%”>
<tr>
<td><div id=”list”></div></td>
</tr>
</table>
Amount : <input type=”text” id=”amount-field”></input>
</body>
<script type=”text/javascript” src=”jqwidgets-ver3/scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets-ver3/jqwidgets/jqx-all.js”></script><script language=”javascript”>
var data1 = [{“merchantId”:”mer0001″,”transactionType”:”1″,”amount”:1.00},{“merchantId”:”mer001″,”transactionType”:”1″,”amount”:1.00},{“merchantId”:”mer001″,”transactionType”:”1″,”amount”:1.04}];
$(document).ready(function(){
$( document ).ajaxError(function( event, request, settings ) {
var emsg = “code:” + request.status + “\n” + “message:” + request.responseText + “\n”;
jpaAlert(emsg, “Error”);
});
var dsource = {
dataType: ‘json’,
localData: data1,
dataFields:
[
{ name: ‘MerchantId’, map: ‘merchantId’ },
{ name: ‘TransactionType’, map: ‘transactionType’ },
{ name: ‘Amount’, map: ‘amount’, type:’float’, format:’c2′ },
],
pageNum: 10,
pageSize:20,
pageable:true,
};
var dataAdapter = new $.jqx.dataAdapter(dsource);$(“#list”).jqxDataTable({
theme: ‘${theme}’,
sortable: true,
pageable:true,
pageSizeOptions: [’10’, ’20’, ’30’, ’50’],
pagerMode: ‘advanced’,
width:’99%’,
columnsResize: true,
enableBrowserSelection:true,
filterable: true,
filterMode:’advanced’,
columns: [
{ text: ‘Merchant’, dataField: ‘MerchantId’, width:’5%’},
{ text: ‘TransactionType’, dataField: ‘TransactionType’, width:’5%’},
{ text: ‘Amount’, dataField: ‘Amount’, width:’5%’, cellsFormat:’c2′ },
]
});
$(“#list”).jqxDataTable({source:dataAdapter});
$(‘#list’).on(‘rowDoubleClick’, function (event) {
var args = event.args;
var row = args.row;
$(“#amount-field”).val(row.Amount);
});});
</script>
</html>
======================================================================================Regards,
Scott KangApril 9, 2015 at 8:00 am in reply to: Formatting a number type value in a cell Formatting a number type value in a cell #69703Hi Peter Stoev,
I managed to display two digits in the list with cellsFormat=’c2′ and without cellsRenderer.
But when I selected the row and displayed the values, the displayed value is still same.How can I display the values correctly?
Regards,
Scott KangApril 7, 2015 at 5:53 am in reply to: Formatting a number type value in a cell Formatting a number type value in a cell #69615Hi Peter,
I changed type of amount field to number. But the result was same.
The records are set after I got data from server with search function.
What may be wrong?function search() {
$.ajax({
type: “POST”,
url: “mca.txn”,
data: “menu=txn&command=search&from=” + from_001 + “&to=” + to_001 +
success: function(data,status){
var dsource = {
dataType: ‘json’,
localData: data,
dataFields:
[
{ name: ‘MerchantId’, map: ‘merchantId’ },
{ name: ‘TransactionType’, map: ‘transactionType’ },
{ name: ‘Xid’, map: ‘xid’ },
{ name: ‘TransactionId’, map: ‘transactionId’ },
{ name: ‘StartTime’, map: ‘startAt’ },
{ name: ‘EndTime’, map: ‘endAt’ },
{ name: ‘ElapsedTime’, map: ‘elapsed’, type:’number’ },
{ name: ‘Amount’, map: ‘amount’, type:’number’ },
{ name: ‘ResponseCode’, map: ‘responseCode’, type:’string’ },
{ name: ‘ResponseMessage’, map: ‘responseMessage’ },
{ name: ‘TxnIdToCancel’, map: ‘xid’ },
{ name: ‘TxnIdToCapture’, map: ‘xid’ },
{ name: ‘SequenceNo’, map: ‘sequenceNo’ },
],
pageNum: 10,
pageSize:20,
pageable:true,
};
}$(document).ready(function(){
$(“#list”).jqxDataTable({
theme: ‘${theme}’,
sortable: true,
pageable:true,
pageSizeOptions: [’10’, ’20’, ’30’, ’50’],
pagerMode: ‘advanced’,
width:’99%’,
columnsResize: true,
enableBrowserSelection:true,
filterable: true,
filterMode:’advanced’,
columns: [
…
{ text: ‘${rb.getString(“Amount”)}’, dataField: ‘Amount’, width:’5%’, cellClassName: cellClass,
cellsRenderer: function(row, column, value, rowData) {
return “” + value;
}
},
…
]
});});
Regards,
Scott Kang -
AuthorPosts