简体   繁体   English

创建动态项目列表并按用户订阅显示项目

[英]Creating a dynamic item list and display the the item as per user subscription

I'm looking to create a dynamic item list of 2 column, but the list item will display as per the user subscription level and other not subscribed items will be hidden. 我正在寻找创建2列的动态项目列表,但是该列表项目将按照用户订阅级别显示,其他未订阅的项目将被隐藏。

For example- I have 10 teams on the list 例如-我名单上有10个团队

Item List 项目清单

 <table width="640" cellspacing="0" cellpadding="0" border="0"> <tr> <td align="center" valign="top" style="font-family:'Open Sans', Arial, Helvetica, sans-serif; font-weight: 600; font-size:15px; color:#003057; mso-line-height-rule:exactly; line-height:18px; padding:0px 0 0px 0;">Your TV Choice lineup</td> </tr> <tr> <td align="left" valign="top" height="15" style="line-height:15px;" ><img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="1" height="15" style="display: block" border="0" /></td> </tr> <tr> <td align="center" valign="middle"> <table width="600" cellspacing="0" cellpadding="0" border="0"> <!-- start if/then statement --> <tr> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL A1] </td> <!-- end if/then statement --> <td align="center" valign="middle" width="20" bgcolor="#ffffff"> <img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="20" height="1" style="display: block" border="0" /> </td> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL B1] </td> <!-- end if/then statement --> </tr> <!-- end if/then statement --> </table> </td> </tr> <tr> <td align="center" valign="middle"> <table width="600" cellspacing="0" cellpadding="0" border="0"> <!-- start if/then statement --> <tr> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#ffffff" height="25"> [COL A2] </td> <!-- end if/then statement --> <td align="center" valign="middle" width="20" bgcolor="#ffffff"> <img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="20" height="1" style="display: block" border="0" /> </td> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#ffffff" height="25"> [COL B2] </td> <!-- end if/then statement --> </tr> <!-- end if/then statement --> </table> </td> </tr> <tr> <td align="center" valign="middle"> <table width="600" cellspacing="0" cellpadding="0" border="0"> <!-- start if/then statement --> <tr> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL A3] </td> <!-- end if/then statement --> <td align="center" valign="middle" width="20" bgcolor="#ffffff"> <img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="20" height="1" style="display: block" border="0" /> </td> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL B3] </td> <!-- end if/then statement --> </tr> <!-- end if/then statement --> </table> </td> </tr> <tr> <td align="center" valign="middle"> <table width="600" cellspacing="0" cellpadding="0" border="0"> <!-- start if/then statement --> <tr> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#ffffff" height="25"> [COL A4] </td> <!-- end if/then statement --> <td align="center" valign="middle" width="20" bgcolor="#ffffff"> <img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="20" height="1" style="display: block" border="0" /> </td> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#ffffff" height="25"> [COL B4] </td> <!-- end if/then statement --> </tr> <!-- end if/then statement --> </table> </td> </tr> <tr> <td align="center" valign="middle"> <table width="600" cellspacing="0" cellpadding="0" border="0"> <!-- start if/then statement --> <tr> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL A5] </td> <!-- end if/then statement --> <td align="center" valign="middle" width="20" bgcolor="#ffffff"> <img src="http://epidm.edgesuite.net/CMS/Coding/Charter/TEMPLATES/CONTENT_ELEMENTS/images/spacer.gif" alt="" width="20" height="1" style="display: block" border="0" /> </td> <!-- start if/then statement --> <td align="center" valign="middle" width="290" bgcolor="#f5f5f7" height="25"> [COL B5] </td> <!-- end if/then statement --> </tr> <!-- end if/then statement --> </table> </td> </tr> </table> 

Scenario 1- If a user is only subscribed to 9 item from the index 0, and index 1 is not subscribed, so the list should be like below, and the not subscribes one will be hidden. 情况1-如果用户仅从索引0订阅了9个项目,而没有订阅索引1,则该列表应如下所示,未订阅者将被隐藏。 (Item list will be shift one previous index) (项目列表将前移一个索引)

COL B5 was hidden COL B5被隐藏
COL B5被隐藏

Scenario 2 - If a user is only subscribed to 5 item from the index 0, so the list should be like below, and the not subscribes one will be hidden. 方案2-如果用户仅从索引0订阅了5个项目,则列表应如下所示,未订阅的用户将被隐藏。

COL B3 to COL B5 was hidden 隐藏了COL B3至COL B5 隐藏了COL B3至COL B5

I am somewhat familiar with HTML, CSS, JavaScript/jQuery. 我对HTML,CSS,JavaScript / jQuery有点熟悉。 I understand that there is a big resource of data for creating online, however, I don't think I found what I was looking for. 我知道有大量的在线创建数据资源,但是,我认为我找不到想要的东西。

If anyone has any solution to this problem in JavaScript/jQuery, that's would be so helpful. 如果有人在JavaScript / jQuery中有解决此问题的任何方法,那将非常有帮助。

Unless you really want to use a table, there is an alternative way of doing this. 除非您真的想使用表,否则还有另一种方法。 (this will only partly answer the question as I'm not writing javascript at 2am Irish time).. (这只会部分回答问题,因为我不是在爱尔兰时间凌晨2点写JavaScript的。)

See the snippet below.. by creating a list with two columns, you can can create a list and then hide elements by setting the visibility to hidden using a "hidden" class. 请参阅下面的代码片段。通过创建具有两列的列表,可以创建列表,然后通过使用“ hidden”类将可见性设置为hidden来隐藏元素。 I made the "table" to have 6 rows a side, and then hid the first row to start off, otherwise the background-colour would have been off/uneven. 我制作了“桌子”,每边有6行,然后将第一行隐藏起来,否则背景颜色会不均匀/不均匀。 When you hide a list item, it will not affect the layout of the background-colour, just don't use display:none; 隐藏列表项时,它不会影响背景色的布局,只是不要使用display:none;。

 #choices { text-align: center; width: 640px; font-family: "Open Sans", Arial, Helvetica; line-height: 1.5; } ul { margin-top: -20px; list-style-type: none; column-count: 2; text-transform: uppercase; } .hidden { visibility: hidden; } li:nth-child(2n) { background-color: #f5f5f7; } 
 <div id="choices"> <h3> Your TV choices </h3> <ul> <li class="hidden">col a1</li> <li>col a1</li> <li>col a2</li> <li>col a3</li> <li>col a4</li> <li>col a5</li> <li class="hidden">col a1</li> <li>col b1</li> <li>col b2</li> <li>col b3</li> <li>col b4</li> <li>col b5</li> </ul> </div> 

This should get you started hopefully! 这应该可以帮助您入门! Here is a fiddle of the snippet with an element hidden 这里是一个小提琴的片段与隐藏的元素

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

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