-
Oct 8th, 2019, 02:33 PM
#1
HTML elements inside an Option element?
So Im looking to do a standard drop down but I need to generate squares of dynamic color "icons" to the left of the text. Ive been googling and have only found this one link but I dont want to add a 3rd party plugin with lots of overkill to the mvc website. Elements are invalid in the Option tag but this one link has done it with jquery.
https://designwithpc.com/Plugins/ddSlick Specifically the uncompressed jquery - https://github.com/prashantchaudhary...ery.ddslick.js
Like the example link but without images, just a div perhaps drawn as a colored square image.
So I use this in js in one of my grids which works well but now I need it in a dropdown. fValue is the html color code formatted like "#ff0000;" which will be populated from @item.Value. The js will need to generate the option element.
Thanks for any insights
Code:
template = "<div style='vertical-align: middle; margin-right: 5px; display: inline-block; width: 20px; height: 20px; border-width: 1px; border-style: solid; border-color: black; background-color: " + fValue + "'></div><span style='vertical-align: middle;'>" + fValue + "</span>";
Code:
<select data-bind="value:Type" title="" data-role="dropdownlist" style="display: none; width: auto;" data-value-field="value" data-text-field="text" data-color-field="color">
<option value="" selected="selected">None</option>
@{
foreach (var item in Model.EventTypes.ListItems)
{
<option value="@item.ListItemID" selected=""> @item.ItemName</option> // NEED THIS CONVERTED TO ADD template
}
}
</select>
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|