简体   繁体   English

最好的方式来显示它?

[英]Best way to display this in a form?

On my website, I have two tables which are linked using a pivot table. 在我的网站上,我有两个使用透视表链接的表。 What I am trying to do is let a user update the relationships between the two tables (inserting and removing records from the pivot table). 我正在尝试做的是让用户更新两个表之间的关系(从数据透视表中插入和删除记录)。 I have no problem doing this in PHP, but what I am concerned about is the way the form is displayed in the users web browser. 我在PHP中执行此操作没有问题,但是我担心的是表单在用户Web浏览器中的显示方式。

The way I am doing it now, is to have a table full of checkboxes, with each checkbox corresponding to a relationship between the column header and the row header (which represent the database tables). 我现在这样做的方法是,在一个充满复选框的表中,每个复选框对应于列标题和行标题(代表数据库表)之间的关系。 The user can check the checkbox to tell the PHP that a record should be present for that relationship (an unchecked box means there is no relationship). 用户可以选中该复选框,以告知PHP该关系应该存在一条记录(未选中的框表示没有关系)。 However this method can get quite ugly (columns stretching outside page bounds) if there are quite a few columns and quite a few rows, and is a bit tedious to use. 但是,如果有很多列和很多行,则此方法可能很难看(列超出页面边界),并且使用起来有点繁琐。

What would be a good way to display this form to the user? 向用户显示此表单的一种好方法是什么?

Maybe use a data grid? 也许使用数据网格? These are quite powerful: 这些功能非常强大:

It may be a time consuming task to make it work through Ajax, though. 但是,使其通过Ajax工作可能是一项耗时的任务。

As this is more about the UI of the application than anything else, I don't think there is going to be a single right answer, as it will come down to a combination of what works (which is difficult without being able to see / play with things) and your personal preferences. 由于这是最重要的应用程序用户界面,因此我认为不会有一个正确的答案,因为它归结为有效的组合(这很难看清/玩)和您的个人喜好。

A few progressions I would run through: 我将经历一些进展:

  • Visual feedback 视觉反馈
    Make you table more interactive by providing visual feedback to the user. 通过向用户提供视觉反馈,使您的表更具交互性。 At the most basic level, try adding some colour to the cells - a colour for those that are checked. 在最基本的层次上,尝试为单元格添加一些颜色-一种用于选中的颜色。 This will allow the user to quickly see which options are "in play". 这将允许用户快速查看哪些选项在“播放中”。 It may be the reverse of this works better (highlighting unchecked cells) - but this all depends what the form is doing / intending to indicate - ie if it's more important to make clear that the unchecked state is bad, you may want these to be red. 这可能是相反的,但效果更好(突出显示未检查的单元格)-但这全都取决于表单的工作/打算指出的内容-即,如果更重要的是要清楚未检查的状态很差,则您可能希望将它们红色。

The next level up is to add some dynamic highlighting. 下一个升级是添加一些动态突出显示。 If the table is huge, you may want to highlight the row and column header cells that correspond the the cell under the cursor. 如果表很大,则可能需要突出显示与光标下的单元格相对应的行和列标题单元格。 You could also consider highlight the whole row / column (cross-hair style) to allow the user to examine 'companion' cells. 您还可以考虑突出显示整个行/列(十字准线样式),以允许用户检查“伴侣”单元格。

  • Dynamic table 动态表
    Slightly more involved would be to add some spice to you table. 稍微涉及的是在表中添加一些香料。 Instead of showing rows and columns of check-boxes, use graphical icons / images. 与其显示复选框的行和列,不如使用图形图标/图像。 They are a lot easier on the eye, and will probably allow you to have tighter control on the dimensions of the table. 它们在眼睛上容易得多,并且可能使您可以更严格地控​​制桌子的尺寸。 The entire UI could then be done via Javascript and on-click - which is pretty easy these days if you employ something like JQuery. 然后,整个UI可以通过Javascript和单击来完成-目前,如果您使用JQuery之类的工具,这非常容易。

  • Split the interface 拆分界面
    This is based on the assumption that all combinations of Table A & Table B aren't setup in the pivot table to begin with - only when a user tries to relate A.item with B.item 这是基于以下假设:仅当用户尝试将A.item与B.item相关时,才在数据透视表中未设置表A和表B的所有组合
    Instead of showing all possible combinations, show only those which are active (have an entry in the pivot table). 除了显示所有可能的组合之外,仅显示活动的组合(在数据透视表中具有一个条目)。 Then provide the user with a second form (probably of two drop-downs) that allows them to relate a record from the first table to the second. 然后为用户提供第二种形式(可能是两个下拉菜单),使他们能够将第一个表中的记录与第二个表相关联。

  • Filter the interface 筛选介面
    Provide the user with the ability to filter the interface - to show only the relationships between a single record from one of the tables. 为用户提供过滤界面的能力-仅显示其中一个表中单个记录之间的关系。 This would have the effect of restricting your table to a single column, making it a bit easier to accommodate in the design. 这将产生将表限制为单个列的效果,使其更易于容纳在设计中。

However, I would still allow the user to get to the "big view" of all records, as, depending on what you are doing, such as view can be very useful to quickly cross reference lots of records. 但是,我仍然允许用户进入所有记录的“大视图”,因为根据您正在执行的操作,例如视图对于快速交叉引用大量记录非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM