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

对zui.datagrid.js的两处意见 #93

Merged
merged 2 commits into from Jan 16, 2018

Conversation

@zora-han
Copy link
Contributor

commented Jan 10, 2018

根据在使用过程中出现的问题,进行的修改

zora-han added 2 commits Jan 10, 2018
修改判断表格内为html还是text
因为判断表格内是填入html片段还是字符串的条件是存在config中的,而不是cell中,故进行此修改
对于获取被选中行信息的修改
在data里面就没有存储过rowId或者id,所以除了在选择标题行时,返回的congfig是唯一的,其余行config返回的rowId均为undefined,所以改为直接判断rowIndex从而赋值给congif.rowId即可
@catouse

This comment has been minimized.

Copy link
Collaborator

commented Jan 10, 2018

第一个意见完全接受;第二个意见有如下问题:
索引仅仅是在界面上显示的顺序,无法永久的与某条数据绑定,有时候无法根据索引来区分数据,所以如果要启用行选中功能,最佳操作是为每条数据指定一个唯一的 ID(源码中的 rowId)。或者当 rowId 没有指定时退化为使用索引。

以后建议将每个功能改动提交一个单独的 Pull Request,这样便于跟踪和讨论。

@zora-han

This comment has been minimized.

Copy link
Contributor Author

commented Jan 11, 2018

那也就是说,如此改动会不会更好一些?之前单纯用索引,确实是欠考虑了
config.rowId = (dataItem && dataItem.rowId)? dataItem.rowId : (rowIndex === 0 ? '#header' : rowIndex);

@catouse

This comment has been minimized.

Copy link
Collaborator

commented Jan 15, 2018

我的想法是这样:

var rowId = dataItem && (dataItem.rowId || dataItem.id);
config.rowId = rowId !== undefined ? rowId : (rowIndex === 0 ? '#header' : rowIndex);

@catouse catouse merged commit 04d9464 into easysoft:master Jan 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.