How to get Tooltip for selected item in DropDownListfor? - html

I couldnt find an attribute "title" for DropdownListFor and was wondering how to do the same for just the selected item in the dropdownlistFor. My code is
#Html.DropDownListFor(m => m.objDetails.CategoryId, new SelectList(Model.objDetails.Categories, "CategoryId", "CategoryName"), new { id = "cboCategory", style = "width:340px;"} )

Source SO
The built-in DropDownList helper doesn't allow you for setting additional HTML attributes on individual options such as title. You will have to write your own custom helper if you want to achieve that. Here's one example

Related

How to make a button to disable elements in a class

I am trying to create a filtering system for a portfolio site in wordpress (using the Divi Builder) and would love to be able to make a button/buttons to set elements with specific classes on a page to display: none when the button is clicked on.
If anyone has ideas on how this can be done that would be super appreciated.
Thanks
If you can use jQuery, the .show() and .hide() Functions work on jQuery objects.
For example $('.dataholder').hide().filter( (index,element) => $("body").innerHTML == "abc" ).show() will hide all nodes with class dataholder and then show those containing abc.
Otherwise you have to use something like
element = document.querySelector('#dataholder')
element.style.display = 'none'
Or
elements = document.querySelectorAll('.dataholder')
elements.forEach( element => element.style.display = 'none' )

How can I use Render sub-template in a C# template in a Content module that uses lists within lists?

2SXC 10.25.2 / DNN 9.3.2
I have a 2sxc module that uses a C# template with "list" enabled. I have a content type called "pathway" and inside that I have 2 entity picker fields for "first step sessions" and then "next step sessions". These entity pickers use a "session" content type. Inside each of those "session" content types I also have an entity picker for "speaker(s)". All in all, it's a setup that I have lists within lists within lists.
When I create the loops for each of the sublists, I can easily do that within the 1 C# template but it becomes repetitive, long, and unruly because there's so much c# code where I'm looping the same session template for different entity picker sections. So, I tried using the "Render sub-template" code to simplify the template - I created new sub templates and inserted them in - it seemed to work at first, however, the template started outputting all "session" items into each item in the list.
I suspect that the subtemplate somehow loses the context of the item that it's in so it's outputting everything. Is there something special I need to know about using subtemplates with for each loops? Do I have to include params and, if so, how do I do that?
EDIT to include code sample:
Here is a small, simplified version of the code I'm working with:
#foreach(var Content in AsList(Data)) {
<h2>#Content.Title</h2>
<h3>Lead Sessions</h3>
<div class="lead-sessions text-green">
#foreach(var item in AsList(Content.LeadSessions as object)){
<h4>#item.LeadSessionTitle</h4>
<p>#item.LeadSessionText</p>
}
</div>
<h3>Next Sessions</h3>
<div class="next-sessions text-green">
#foreach(var nextitem in AsList(Content.NextSessions as object)){
<h4>#nextitem.LeadSessionTitle</h4>
<p>#nextitem.LeadSessionText</p>
}
</div>
}
I want to make a subtemplate so I don't have to repeat the same code for the sessions loop. How could I simplify this template to use a subtemplate for looping the sessions within the lead-sessions and next-sessions?
So based on the modified question, it's a bit like this
#foreach(var Content in AsList(Data)) {
<h2>#Content.Title</h2>
<h3>Lead Sessions</h3>
#RenderPage("_inner.cshtml", new { Items = Content.LeadSessions })
<h3>Next Sessions</h3>
#RenderPage("_inner.cshtml", new { Items = Content.NextSessions })
}
Second file _inner.cshtml
#{
var items = AsList(PageData["Items"]);
}
<div class="next-sessions text-green">
#foreach(var nextitem in items){
<h4>#nextitem.LeadSessionTitle</h4>
<p>#nextitem.LeadSessionText</p>
}
</div>
Yep, you can just use RenderPage without params, or pass in params like in the blog app:
#RenderPage("shared/_Category Filter.cshtml", new { MobileView = true, FilteredCategory = filteredCategory })
See https://github.com/2sic/app-blog/blob/master/_List.cshtml#L25
Then the template can retrieve the values like
#{
var filteredCategory = PageData["FilteredCategory"];
}
See https://github.com/2sic/app-blog/blob/master/shared/_Category%20Filter.cshtml#L6
You can pass around any amount of values/objects like this.
You can also create helpers - and then call those helpers. Like this
https://github.com/2sic/app-news/blob/master/shared/_Helpers.cshtml#L24-L33

VueJs component names

I'm working in VueJS and i have the following code
<li #click = "selectedComponent = 'appManagment'"><i class="ion-clipboard"></i>Management</li>
so what i try to accomplish is to display the name like {{selectedComponent}}
but as excpected it displays "appManagment" because this is the component that was selected.
So the question is, how to display a different name, for example i want just "Managment" to appear instead of "appManagment".
I'm using it for the navigation menu that displays where the user is located, so any help would be appreciated.
I would create an object like the one below
var prettyNames = {
'appManagment': 'Some very nice name'
}
and then just use it whenever you want to display text which corresponds to the currently selected component. For example
prettyNames[selectedComponent]
You can register a custom filter with the global Vue.filter() method, passing in a filterID and a filter function. The filter function takes a value as the argument and returns the transformed value:
Vue.filter('custom', function (value) {
// add your code to determine
// name based on value here
return newName;
})
Then use your filter on the text:
<i class="ion-clipboard"></i>{{ selectedComponent | custom }}

Kendo UI - DropdownList in MVC Grid Edit/Create Popup

I've seen the other questions similar to this one, but it seems like I've done everything right so far, to no avail.
As the title states, for one of my columns, I am trying to use a dropdownlist as the field in the popup.
Index.cshtml:
.Columns(columns =>
{
columns.Bound(p => p.DEPT_ID).Width("7%").Title("Dept/ Sector").EditorTemplateName("DeptDropdown");
...
}
Then inside of /Views/Shared/EditorTemplates
DeptDropdown.cshtml:
#model MVCFinalHope.Models.Version_Utility_Model
#(Html.Kendo().DropDownListFor(m => m.DeptLookup )
.Name("DEPT_ID")
.DataValueField("DEPT_ID")
.DataTextField("DEPT_ID")
.BindTo(Model.DeptLookup)
)
Then inside of Version_Utility_Model.cs:
[UIHint("DeptDropdown")]
public List<V_TE_DEPT_LKUP> DeptLookup { get; set; }
Standalone custom field editors don't work in popup edit mode. You need to use a template for the whole edit form:
https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/custom-popup-editor
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates
If the Grid is configured for pop-up editing, the Html.EditorForModel is used to get the editor HTML for the whole model.

Kendo UI batch edit grid DropDownList does not show up

I am using a kendo ui batch edit grid and I want to use a dropdown as a column of it.
I read other topics about this subject and I did these steps:
1- I created a list of text/value and named it as
DocumetTypesSelectList in a viewbag like this:
ViewBag.DocumetTypesSelectList = DocumentTypesBll.GetDocumentTypes().ToList().Select(item => new SelectListItem
{
Value = item.DocumentTypeId.ToString(),
Text = item.Title
}).ToList();
2- I Cast the viewbag as a list of SelectItems in my view like this:
var DocumetTypesSelectList = ViewBag.DocumetTypesSelectList as List<SelectListItem> ?? new List<SelectListItem>();
3- I added a column to grid as follows:
columns.ForeignKey(p => p.DocumentTypeId, (System.Collections.IEnumerable)DocumetTypesSelectList, dataFieldText: "Text", dataFieldValue: "Value")
but it does not open to select on of the items. on click you can change the value, and off click it shows the text using DocumetTypesSelectList .
Thanks In Advance
many thanks for your help
Please explain little bit more about
on click you can change the value, and off click it shows the text
It seems that here (System.Collections.IEnumerable)DocumetTypesSelectList you have missed your DocumetTypesSelectList object to pass on properly. You can do this in your controller by using ViewBag as ViewBag.DocumetTypesSelectListEx = DocumetTypesSelectList and use this ViewBag in your view as (System.Collections.IEnumerable)ViewBag.DocumetTypesSelectListEx
Second thing is, in your DocumetTypes you must have two fields one is for value and one is to display. It seems you have both as "Text" and "Value". Also check the demo here