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

QQ登录

只需一步,快速开始

X.ss

注册会员

1

主题

3

帖子

10

积分

注册会员

积分
10
  • 35

    金币

  • 1

    主题

  • 3

    帖子

最新发帖
X.ss
注册会员   /  发表于:2025-6-6 10:01  /   查看:108  /  回复:4
1金币
现项目中使用的是FlexGrid
功能
      Grid中每一行有一个输入框,编辑成功后,会在Grid的最下面添加编辑前的行。(因为前开发人员的问题,没有使用Collection.addNew()方法,直接操作在Collection的数据源中添加数据,然后刷新Grid)
问题
      现在有一个情况是,当我编辑完输入框时,按下回车,焦点离开当前行后,添加的数据可以通过Grid.refresh()显示到页面上。如果我不按下回车按钮,点击当前行的其他Cell时,或者按下其他不会导致焦点离开当前行的按键时,添加的数据不能通过Grid.refresh()显示到页面上,我确定数据已经添加进去。个人总结,只有发生焦点离开当前行这个事件时,才添加的数据才会显示到页面上。现在想解决这个问题,请问有什么方法吗?


4 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2025-6-6 16:28:30
沙发
你应该用collectionview的refresh方法拉刷新数据,而不是grid.refresh

https://demo.grapecity.com.cn/wi ... onview.html#refresh
回复 使用道具 举报
X.ss
注册会员   /  发表于:2025-6-6 16:54:02
板凳
Richard.Ma 发表于 2025-6-6 16:28
你应该用collectionview的refresh方法拉刷新数据,而不是grid.refresh

https://demo.grapecity.com.cn/w ...

您好,两种refresh都试过了没有效果。
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2025-6-9 15:38:41
地板
你可以用这个demo看看怎么修改能复现问题,然后把需要修复的代码发上来我复现一下

https://demo.grapecity.com.cn/wi ... dingRemoving/purejs
回复 使用道具 举报
X.ss
注册会员   /  发表于:前天 17:25
5#
Richard.Ma 发表于 2025-6-9 15:38
你可以用这个demo看看怎么修改能复现问题,然后把需要修复的代码发上来我复现一下

https://demo.grapeci ...



<template>
    <div class="container-fluid">
        <wj-flex-grid :initialized="initData"
            :itemsSource="grid.data"
            :cellEditEnding="onValueChanged">
        </wj-flex-grid>
    </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,
                    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,
                        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(){
                let newData = {
                    id: Math.random(),
                    country: "newData",
                    downloads: Math.round(Math.random() * 20000),
                    sales: Math.random() * 10000,
                    expenses: Math.random() * 5000
                }
                data.push(newData);
                this.grid.collectionView.refresh();
            }
        }
    })

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

<style>
.wj-flexgrid {
    height: 200px;
    margin: 10px 0;
}
body {
    margin-bottom: 20pt;
}
</style>






差不多就是上面的功能,当我编辑cellEditEnding时,给itemsSource追加一行新数据,并显示,但是会发生上面所描述的情况。

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