Browse Source

费率文件代码优化。

Chenshilong 8 years ago
parent
commit
1ca6c9b0c9
1 changed files with 16 additions and 13 deletions
  1. 16 13
      web/fees/feeRate.js

+ 16 - 13
web/fees/feeRate.js

@@ -70,7 +70,7 @@ function loadLibFeeRates(libID) {
     });
 }
 
-function createSpreadView(data, canEdit) {
+function createSpreadView(datas, canEdit) {
     // 创建前先销毁旧树表。
     //$('#divFee').empty();  // 清空不行,浏览器跟踪显示错误数狂飚:TypeError: G is null
     //$('#divFee').remove(); // 删除可以,但是太山寨。
@@ -86,7 +86,8 @@ function createSpreadView(data, canEdit) {
             id: 'name',
             caption: '名称',
             dataField: 'name',
-            width: 250
+            width: 250,
+            allowEditing: false
         },
         {
             id: 'rate',
@@ -94,38 +95,45 @@ function createSpreadView(data, canEdit) {
             dataField: 'rate',
             format: '0.000',
             width: 80,
-            minWidth: 50
+            minWidth: 50,
+            allowEditing: true
         },
         {
             id: 'memo',
             caption: '说明',
             dataField: 'memo',
             width: 200,
-            minWidth: 120
+            minWidth: 120,
+            allowEditing: false
         },
         {
             id: 'ID',
             caption: 'ID',
             dataField: 'ID',
             width: 80,
-            visible: false
+            visible: false,
+            allowEditing: false
         },
         {
             id: 'ParentID',
             caption: '父结点ID',
             dataField: 'ParentID',
             width: 80,
-            visible: false
+            visible: false,
+            allowEditing: false
         }
     ];
 
-    var option = {
+    var options = {
         allowSorting: false,
         showRowHeader: true,
         colMinWidth: 80,
         colHeaderHeight: 35,
         rowHeight: 30,
         allowEditing: canEdit,
+        editMode: 'inline',
+        editUnit: 'cell',
+        selectionUnit: (canEdit == true) ? "cell" : "row",
         hierarchy: {
             keyField: 'ID',
             parentField: 'ParentID',
@@ -135,12 +143,7 @@ function createSpreadView(data, canEdit) {
     };
 
     spreadView = new GC.Spread.Views.DataView($('#divFee')[0],
-        data, columns, new GC.Spread.Views.Plugins.GridLayout(option));
-    var opts = spreadView.layoutEngine.options;
-    opts.editMode = 'inline';
-    opts.editUnit = 'cell';
-    if (canEdit){ opts.selectionUnit = 'cell'; }
-    else{ opts.selectionUnit = 'row'; }
+        datas, columns, new GC.Spread.Views.Plugins.GridLayout(options));
     spreadView.invalidate();
     document.querySelector('#divFee').focus();
 }