jQuery MiniUI

 找回密码
 立即注册
查看: 2947|回复: 5
打印 上一主题 下一主题

datagrid渲染问题 [复制链接]

Rank: 4

跳转到指定楼层
楼主
发表于 2019-9-23 15:35:19 |只看该作者 |倒序浏览
页面加载进来的时候就触发了vue的updated方法,这时候操作列的渲染是正确的,这时候没有修改的数据,所以write为true,我保存完成后,点击提交按钮使用vue重新获取回来数据,再次执行updated方法,更新了表格内的数据,已经进入了index的判断,而且断点查看write也为false,可是执行到drawcell方法里的时候 去判断操作列的时候write还是true

updated:function () {            mini.parse();            if(this.grid!=''){                if(this.isForm){                    if(this.formid!=''){                        readOnly(this.formid);                    }                }else {                    var grid = mini.get(this.grid);                    var index = $('#'+this.grid).parents('.maintainContent').attr('attr');                    var write = true;                    if(index){                        if(this.datas[index].TexamineData&&this.datas[index].TexamineData.length>0){                                write = false;                                grid.setData(this.datas[index].TexamineData);                        }else{                            grid.setData(mini.decode(this.datas[index].data));                        }                    }                    var that = this;                    grid.on("drawcell", function (e) {                        var record = e.record,                                column = e.column,                                field = e.field,                                value = e.value;                        //翻译                        if(column.name!=undefined&&column.name != "action"){                            var items = formVue.datas[index].codeSet[column.name];                            for (var item in items){                                if(items[item].id == e.cellHtml){                                    e.cellHtml =  items[item].text;                                }                            }                        }                        //action列,超连接操作按钮                        if (column.name == "action") {                            e.cellStyle = "text-align:center";                            if(write){                                e.cellHtml = '<a class="button_form_see inline_block"  alt="查看" title="查看" class="editClass" style="cursor: pointer;"o" style="color: rgb(102, 102, 102);">+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '                                +'<a class="button_form_operation inline_block"  alt="修改" title="修改" class="editClass" style="cursor: pointer;"o" style="color: rgb(102, 102, 102);">+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '                                + '<a class="button_form_delete inline_block" o" style="color: rgb(102, 102, 102);">+record._uid+')" id="'+record.SUBID+'" attr="'+that.grid+'" width="16" style="cursor: pointer;" alt="删除" title="删除"></a>'                            }else{                                e.cellHtml = '<a class="button_form_see inline_block"  alt="查看" title="查看" class="editClass" style="cursor: pointer;"o" style="color: rgb(102, 102, 102);">+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '                            }                        }                    });                }            }                  },

Rank: 8Rank: 8

沙发
发表于 2019-9-23 15:55:56 |只看该作者
本帖最后由 felt 于 2019-9-23 16:06 编辑

你这遇到了什么问题,drawcell的时候需要处理什么?

Rank: 4

板凳
发表于 2019-9-23 16:06:12 |只看该作者
felt 发表于 2019-9-23 15:55
你这yf了什么问题,drawcell的时候需要处理什么?

更新数据的时候,drawcell的需要更改操作列的按钮一开始有三个,现在要改成一个

Rank: 8Rank: 8

地板
发表于 2019-9-23 16:08:41 |只看该作者
lys373113838 发表于 2019-9-23 16:06
更新数据的时候,drawcell的需要更改操作列的按钮一开始有三个,现在要改成一个 ...

drawcell的时候分支判断处理
需要绘制一个按钮就绘制一个,绘制多个就绘制多个

Rank: 4

5#
发表于 2019-9-23 16:32:23 |只看该作者
felt 发表于 2019-9-23 16:08
drawcell的时候分支判断处理
需要绘制一个按钮就绘制一个,绘制多个就绘制多个 ...

判断了啊,而且在执行drawcell的之前write已经设置为false了,可是在判断的时候还是true,很诡异
if (column.name == "action") {
                            e.cellStyle = "text-align:center";
                            if(write){
                                e.cellHtml = '<a class="button_form_see inline_block"  alt="查看" title="查看" class="editClass" style="cursor: pointer;" onclick="lookRow('+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '
                                +'<a class="button_form_operation inline_block"  alt="修改" title="修改" class="editClass" style="cursor: pointer;" onclick="editRow('+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '
                                + '<a class="button_form_delete inline_block"  onclick="tableDel('+record._uid+')" id="'+record.SUBID+'" attr="'+that.grid+'" width="16" style="cursor: pointer;" alt="删除" title="删除"></a>'
                            }else{
                                e.cellHtml = '<a class="button_form_see inline_block"  alt="查看" title="查看" class="editClass" style="cursor: pointer;" onclick="lookRow('+record._uid+')" id="'+that.grid+'" data='+JSON.stringify(record)+'></a> '
                            }
                        }

Rank: 8Rank: 8

6#
发表于 2019-9-23 16:40:16 |只看该作者
lys373113838 发表于 2019-9-23 16:32
判断了啊,而且在执行drawcell的之前write已经设置为false了,可是在判断的时候还是true,很诡异
if (col ...

我的意思是让你在drawcell的时候重新来处理write,而不是根据前面处理好的write来绘制

Archiver|普加软件

GMT+8, 2024-5-3 05:26 , Processed in 1.036493 second(s), 9 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部