1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title></title>
- <link href="../../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet"
- type="text/css" />
- <script src="../../../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
- <script src="../../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
- <script src="../../../lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
- <script src="../ProductData.js" type="text/javascript"></script>
- <script type="text/javascript">
- //扩展currency类型的格式化函数
- $.ligerDefaults.Grid.formatters['currency'] = function (num, column) {
- //num 当前的值
- //column 列信息
- if (!num) return "$0.00";
- num = num.toString().replace(/\$|\,/g, '');
- if (isNaN(num))
- num = "0.00";
- sign = (num == (num = Math.abs(num)));
- num = Math.floor(num * 100 + 0.50000000001);
- cents = num % 100;
- num = Math.floor(num / 100).toString();
- if (cents < 10)
- cents = "0" + cents;
- for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
- num = num.substring(0, num.length - (4 * i + 3)) + ',' +
- num.substring(num.length - (4 * i + 3));
- return "$" + (((sign) ? '' : '-') + '' + num + '.' + cents);
- };
- $(function ()
- {
- $("#maingrid").ligerGrid({
- columns: [
- {display: '产品', columns:
- [
- { display: '主键', name: 'ProductID', type: 'int'},
- { display: '产品名', name: 'ProductName', align: 'left', width: 100 },
- { display: '单价', name: 'UnitPrice', align: 'right' ,type:'currency' }
- ]
- },
- { display: '仓库数量', name: 'UnitsInStock', align: 'right', type: 'float'}
- ], data: ProductData
- });
- });
- </script>
- </head>
- <body>
- <div id="maingrid">
- </div>
- <div style="display: none;">
- </div>
- </body>
- </html>
|