本帖最后由 阿Zzzz 于 2023-10-16 14:27 编辑
可编辑列的isRequired值设置为默认值(null)
现象一:
第一行数据的改列值为null,该列的其他行即使有值也删不掉
现象二:
第一行数据的改列值不为null,该列的其他行如果有值可以删掉
想知道最初的预想现象是什么~~isRequired默认值的应场景应该是什么
※country为例
现象一代码:
- <template>
- <div class="container-fluid">
- <!-- the grid -->
- <wj-flex-grid
- :itemsSource="data"
- :initialized="initializeGrid">
- <wj-flex-grid-column binding="id" header="ID" :width=50 :isReadOnly=true></wj-flex-grid-column>
- <wj-flex-grid-column binding="country" header="Country"></wj-flex-grid-column>
- <wj-flex-grid-column binding="sales" header="Sales" :isRequired=false></wj-flex-grid-column>
- <wj-flex-grid-column binding="expenses" header="Expenses" :isRequired=false></wj-flex-grid-column>
- <wj-flex-grid-column binding="overdue" header="Overdue"></wj-flex-grid-column>
- </wj-flex-grid>
- </div>
- </template>
- <script>
- import "@grapecity/wijmo.styles/wijmo.css";
- import "bootstrap.css";
- import Vue from "vue";
- import { WjGridModule } from '@grapecity/wijmo.vue2.grid';
- import * as wjcGrid from '@grapecity/wijmo.grid';
- new Vue({
- el: "#app",
- data: {
- data: null
- },
- methods:{
- initializeGrid(flex){
- this.data = this._getData();
- flex.beginningEdit.addHandler((s, e) => {
- let item = s.rows[e.row].dataItem;
- if (item.overdue) { // prevent editing overdue items
- e.cancel = true;
- }
- });
- },
- _getData() {
- // create some random data
- let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
- data = [];
- data.push({
- id: '-1',
- country: null,
- sales: Math.random() * 10000,
- expenses: Math.random() * 5000,
- });
- for (let i = 0; i < countries.length; i++) {
- data.push({
- id: i,
- country: countries[i],
- sales: Math.random() * 10000,
- expenses: Math.random() * 5000,
- overdue: i % 4 == 0
- });
- }
- return data;
- }
- }
- });
- </script>
- <style>
- .wj-flexgrid {
- max-height: 200px;
- margin-bottom: 12px;
- }
- body {
- margin-bottom: 24px;
- }
- </style>
复制代码 现象二代码:
- <template>
- <div class="container-fluid">
- <!-- the grid -->
- <wj-flex-grid
- :itemsSource="data"
- :initialized="initializeGrid">
- <wj-flex-grid-column binding="id" header="ID" :width=50 :isReadOnly=true></wj-flex-grid-column>
- <wj-flex-grid-column binding="country" header="Country"></wj-flex-grid-column>
- <wj-flex-grid-column binding="sales" header="Sales" :isRequired=false></wj-flex-grid-column>
- <wj-flex-grid-column binding="expenses" header="Expenses" :isRequired=false></wj-flex-grid-column>
- <wj-flex-grid-column binding="overdue" header="Overdue"></wj-flex-grid-column>
- </wj-flex-grid>
- </div>
- </template>
- <script>
- import "@grapecity/wijmo.styles/wijmo.css";
- import "bootstrap.css";
- import Vue from "vue";
- import { WjGridModule } from '@grapecity/wijmo.vue2.grid';
- import * as wjcGrid from '@grapecity/wijmo.grid';
- new Vue({
- el: "#app",
- data: {
- data: null
- },
- methods:{
- initializeGrid(flex){
- this.data = this._getData();
- flex.beginningEdit.addHandler((s, e) => {
- let item = s.rows[e.row].dataItem;
- if (item.overdue) { // prevent editing overdue items
- e.cancel = true;
- }
- });
- },
- _getData() {
- // create some random data
- let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
- data = [];
- for (let i = 0; i < countries.length; i++) {
- data.push({
- id: i,
- country: countries[i],
- sales: Math.random() * 10000,
- expenses: Math.random() * 5000,
- overdue: i % 4 == 0
- });
- }
- return data;
- }
- }
- });
- </script>
- <style>
- .wj-flexgrid {
- max-height: 200px;
- margin-bottom: 12px;
- }
- body {
- margin-bottom: 24px;
- }
- </style>
复制代码
|