Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

表格内容编辑时,不会把数据带到编辑页吗? #61

Open
nanqic opened this issue Apr 3, 2021 · 2 comments
Open

表格内容编辑时,不会把数据带到编辑页吗? #61

nanqic opened this issue Apr 3, 2021 · 2 comments

Comments

@nanqic
Copy link

nanqic commented Apr 3, 2021

table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
如题,请问默认不把data传到edit页面吗?怎么在edit页拿到data数据?

想到了这个解决办法,请问原始有简便的方法没?
// 对所选编辑行数据编码
var data = escape(JSON.stringify(obj.data));
if (obj.event === 'edit') {
var index = layer.open({
title: '编辑用户',
type: 2,
content: './table/user-edit.html?'+data,
// 编辑页解码,得到原始对象
console.log(JSON.parse(unescape(location.search).replace('?','')))

@wnwy0214
Copy link

wnwy0214 commented Apr 4, 2021

你试试这个
var dataJson;
layui.use('table', function(){
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
// 给dataJson 赋值
var data = JSON.stringify(data);
var index = layer.open({
title: '编辑用户',
type: 2,
content: './table/user-edit.html',
})
// 然后在编辑页获取dataJson
获取dataJson = eval ('('+parent.dataJson+')');
这个应该可以

@nanqic
Copy link
Author

nanqic commented Apr 6, 2021

谢谢,我试了半天,然后想起来我这是两个页面,你给的方法适用于嵌套iframe的父子页面传值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants