请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

eeg1412

注册会员

12

主题

20

帖子

82

积分

注册会员

积分
82
eeg1412
注册会员   /  发表于:2020-4-9 10:54  /   查看:3224  /  回复:1
1金币
如题
如果使用自定义编辑器的话会导致禁止编辑的
e.cancel = true;
失效

例子
  1. <template>
  2.     <div class="container-fluid">
  3.         <wj-flex-grid :keyActionTab="'CycleOut'" :initialized="initializeGrid" :itemsSource="itemSourceData">
  4.             <wj-flex-grid-column :binding="'id'" :header="'ID'" :width="40" :isReadOnly="true"></wj-flex-grid-column>
  5.             <wj-flex-grid-column :binding="'date'" :header="'Date'" :format="'d'"></wj-flex-grid-column>
  6.             <wj-flex-grid-column :binding="'time'" :header="'Time'" :format="'t'"></wj-flex-grid-column>
  7.             <wj-flex-grid-column :binding="'country'" :header="'Country'"></wj-flex-grid-column>
  8.             <wj-flex-grid-column :binding="'product'" :header="'Product'"></wj-flex-grid-column>
  9.             <wj-flex-grid-column :binding="'amount'" :header="'Amount'" :format="'n2'"></wj-flex-grid-column>
  10.         </wj-flex-grid>
  11.     </div>
  12. </template>

  13. <script>
  14. import "@grapecity/wijmo.styles/wijmo.css";
  15. import "bootstrap.css";
  16. import Vue from "vue";
  17. import * as wjcCore from "@grapecity/wijmo";
  18. import * as wjcInput from "@grapecity/wijmo.input";
  19. import * as wjcGrid from "@grapecity/wijmo.grid";
  20. import { WjInputModule } from "@grapecity/wijmo.vue2.input";
  21. import { WjGridModule } from "@grapecity/wijmo.vue2.grid";
  22. import { CustomGridEditor } from "./custom-grid-editor";

  23. let App = Vue.extend({
  24.     name: "app",
  25.     data: function() {
  26.         return {
  27.             countries: "US,Germany,UK,Japan,Italy,Greece".split(","),
  28.             products: [
  29.                 { id: 0, name: "Widget", unitPrice: 23.43 },
  30.                 { id: 1, name: "Gadget", unitPrice: 12.33 },
  31.                 { id: 2, name: "Doohickey", unitPrice: 53.07 }
  32.             ],
  33.             itemSourceData: null,
  34.         };
  35.     },
  36.     methods: {
  37.         initializeGrid: function(flex) {
  38.             // add custom editors to the grid
  39.             new CustomGridEditor(flex, "date", wjcInput.InputDate, {
  40.                 format: "d"
  41.             });
  42.             new CustomGridEditor(flex, "time", wjcInput.InputTime, {
  43.                 format: "t",
  44.                 min: new Date(2000, 1, 1, 7, 0),
  45.                 max: new Date(2000, 1, 1, 22, 0),
  46.                 step: 30
  47.             });
  48.             new CustomGridEditor(flex, "country", wjcInput.ComboBox, {
  49.                 itemsSource: this.countries
  50.             });
  51.             new CustomGridEditor(flex, "amount", wjcInput.InputNumber, {
  52.                 format: "n2",
  53.                 step: 10
  54.             });
  55.             flex.beginningEdit.addHandler((s, e) => {
  56.                     e.cancel = true;
  57.                 });
  58.             //
  59.             // create an editor based on a ComboBox
  60.             let multiColumnEditor = new CustomGridEditor(
  61.                 flex,
  62.                 "product",
  63.                 wjcInput.ComboBox,
  64.                 {
  65.                     headerPath: "name",
  66.                     displayMemberPath: "name",
  67.                     itemsSource: this.products
  68.                 }
  69.             );
  70.             //
  71.             // customize the ComboBox to show multiple columns
  72.             let combo = multiColumnEditor.control;
  73.             combo.listBox.formatItem.addHandler((s, e) => {
  74.                 e.item.innerHTML =
  75.                     "<table><tr>" +
  76.                     '<td style="width:30px;text-align:right;padding-right:6px">' +
  77.                     e.data.id +
  78.                     "</td>" +
  79.                     '<td style="width:100px;padding-right:6px"><b>' +
  80.                     e.data.name +
  81.                     "</b></td>" +
  82.                     '<td style="width:80px;text-align:right;padding-right:6px">' +
  83.                     wjcCore.Globalize.format(e.data.unitPrice, "c") +
  84.                     "</td>" +
  85.                     "</tr></table>";
  86.             });
  87.         },

  88.         getData: function() {
  89.             let data = [];
  90.             let dt = new Date();
  91.             for (let i = 0; i < 100; i++) {
  92.                 data.push({
  93.                     id: i,
  94.                     date: new Date(
  95.                         dt.getFullYear(),
  96.                         i % 12,
  97.                         25,
  98.                         i % 24,
  99.                         i % 60,
  100.                         i % 60
  101.                     ),
  102.                     time: new Date(
  103.                         dt.getFullYear(),
  104.                         i % 12,
  105.                         25,
  106.                         i % 24,
  107.                         i % 60,
  108.                         i % 60
  109.                     ),
  110.                     country: this.countries[
  111.                         Math.floor(Math.random() * this.countries.length)
  112.                     ],
  113.                     product: this.products[
  114.                         Math.floor(Math.random() * this.products.length)
  115.                     ].name,
  116.                     amount: Math.random() * 10000 - 5000,
  117.                     discount: Math.random() / 4
  118.                 });
  119.             }
  120.             return data;
  121.         }
  122.     },
  123.     mounted:function(){
  124.         this.itemSourceData = this.getData();
  125.     }
  126. });

  127. new Vue({ render: h => h(App) }).$mount("#app");
  128. </script>

  129. <style>
  130. .wj-flexgrid {
  131.     height: 300px;
  132.     margin-bottom: 12px;
  133. }

  134. .wj-flexgrid .wj-cell {
  135.     padding: 6px 3px;
  136. }

  137. body {
  138.     margin-bottom: 24px;
  139. }
  140. </style>
复制代码


最佳答案

查看完整内容

你好,在这个示例中: https://demo.grapecity.com.cn/wijmo/demos/Grid/Editing/CustomEditors/purejs _beginningEdit方法里可以自行添加条件,判断是否继续执行,如果直接return即可实现禁止编辑的效果,如图:

1 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-4-9 10:54:27
来自 2#
你好,在这个示例中:

https://demo.grapecity.com.cn/wi ... ustomEditors/purejs

_beginningEdit方法里可以自行添加条件,判断是否继续执行,如果直接return即可实现禁止编辑的效果,如图:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部