本帖最后由 KevinChen 于 2020-3-25 14:21 编辑
您好,感谢您的反馈!问题已经重现!
初步分析是在刷新时重排flexGrid的布局时没有触发自适应的机制,如果在grid的host dom上设置固定宽高时会触发这个问题。
暂时可以利用refresh解决这个问题,关键代码如下:
- <div class="blockcode"><blockquote> delRow(n){
- this.grid.instance.collectionView.removeAt(n);
- console.log(1);
- var grid = this.grid;
- setTimeout(function(){
- grid.instance.refresh(true);
- }, 10)
- },
复制代码
在您提供的示例中,可以拷贝以下代码来查看效果:
- <div class="blockcode"><blockquote><template>
- <div class="container-fluid" >
- <label>
- newRowAtTop
- <input v-model="grid.newRowAtTop" @change="onValueChanged" type="checkbox">
- </label>
- <wj-flex-grid :initialized="initData"
- :allowAddNew="true"
- :allowDelete="true"
- :itemsSource="grid.data"
- :newRowAtTo="grid.newRowAtTop" style="height:225px;">
- <wj-flex-grid-column binding="id" header="ID" :width="'*'"></wj-flex-grid-column>
- <wj-flex-grid-column binding="country" header="国" :width="'*'"></wj-flex-grid-column>
- <wj-flex-grid-column binding="downloads" header="DL数" :width="'*'"></wj-flex-grid-column>
- <wj-flex-grid-column binding="sales" header="売上" :width="'*'"></wj-flex-grid-column>
- <wj-flex-grid-column binding="expenses" header="費用" :width="'*'"></wj-flex-grid-column>
- </wj-flex-grid>
- <button type="button" @click="delRow(1)">delete</button>
- </div>
- </template>
- <script>
- import "@grapecity/wijmo.styles/wijmo.css";
- import 'bootstrap.css';
- import Vue from 'vue';
- import '@grapecity/wijmo.vue2.core';
- import '@grapecity/wijmo.vue2.grid';
- let App = Vue.extend({
- name: 'app',
- data: function(){
- return {
- grid: {
- data: null,
- newRowAtTop: false,
- instance: null
- }
- }
- },
- methods: {
- getData: function(s, e){
- 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],
- downloads: Math.round(Math.random() * 20000),
- sales: Math.random() * 10000,
- expenses: Math.random() * 5000
- });
- }
- return data;
- },
- initData: function(grid){
- this.grid.instance = grid;
- this.grid.data = this.getData();
- },
- onValueChanged: function(){
- this.grid.instance.newRowAtTop = this.grid.newRowAtTop;
- },
- delRow(n){
- this.grid.instance.collectionView.removeAt(n);
- console.log(1);
- var grid = this.grid;
- setTimeout(function(){
- grid.instance.refresh(true);
- }, 10)
- },
- }
- })
- new Vue({ render: h => h(App) }).$mount('#app');
- </script>
- <style>
- .wj-flexgrid {
- height: 200px;
- margin: 10px 0;
- }
- body {
- margin-bottom: 20pt;
- }
- </style>
复制代码
|