Set kendo ui dropdownlist width - user-interface

I would like to use a kendo drop-down list, which has a fixed size since is constrained by other fields in the page, but when it shows the drop-down items of the list, the drop-down area should resize to the maximum length of the items. Sort of fixed width for the item displayed, but auto width for the drop down list.
Something like
|my choice | <-- fixed width displayed on the page
|next choice |
|previous choice | <-- dropdown area to select another item
|dummy |
Is this possible through CSS or drop-down list properties set through jQuery?

You can set the width of a DropDown List both using a CSS or using a method.
If the id of you DropDownList is my-dropdown then you should write:
Using CSS
#my-dropdown-list {
width: auto !important;
}
NOTE: We have appended -list to the original id. The "!important" is important since you want to overwrite original width definition.
Using a method
$("#my-dropdown").data("kendoDropDownList").list.width("auto");
In addition to use "auto" for getting the width automatically adjusted to the text, you can use a fixed width:
#my-dropdown-list {
width: 300px !important;
}
or:
$("#my-dropdown").data("kendoDropDownList").list.width(300);

The above answer didn't work for me. I have a the advantage of knowing that my dropdown is inside of a div.
<div class="myDivClass">
<select id="myDropDown"><option>First</option><option>Second></option></select>
<!--... other stuff in the div-->
<div>
I found that the span has the class k-dropdown so I added the CSS
.myDivClass span.k-dropdown {
width: 300px
}

What worked for me is to render an extra class on the base element:
<input .. class="ExtraLarge ..
Which produced:
<span style="" class="k-widget k-dropdown k-header ExtraLarge" ..
With this ExtraLarge class in place, this worked great in FireFox and Chrome:
span.k-dropdown.ExtraLarge
{
width:400px;
}

Using the following code to be the template of the kendo dropdownlist:
<div class="myDivClass">
<select id="myDropDown"><option>First</option><option>Second></option></select>
<!--... other stuff in the div-->
<div>
you will initiate the kendoDropDownList using jQuery as follows:
$("#myDropDown").kendoDropDownList().data("kendoDropDownList");
Now, to set this controller to take up the full width, what you have to do, is to set the width of the select element to 100%, or whatever is your desire.
e.g.:
<select id="myDropDown" style="width: 100%"><option>First</option><option>Second></option></select>
OR, is a css file:
#myDropDown { width: 100% }

If the id of you DropDownList is my-dropdown then you should write:
#my-dropdown-list {
width: auto !important;
-moz-min-width: 120px;
-ms-min-width: 120px;
-o-min-width: 120px;
-webkit-min-width: 120px;
min-width: 120px;
/*max-width: 210px;*/
}
Read the explanation below.
http://docs.telerik.com/kendo-ui/controls/editors/dropdownlist/how-to/auto-adjust-the-width

Related

How to get rounded corners for pop up in kendo ui for dropdown list

how to get rounded corners in the popup of the dropdown list?
<div class="example-wrapper">
<p>T-shirt size:</p>
<kendo-dropdownlist [data]="listItems"
[popupSettings]="{
popupClass:'[border-round]'
}">
</kendo-dropdownlist>
</div>
where border round is defined in the css as
.border-round
{
border-radius:20px;
}
i tried this and it does not work
In Kendo UI for jQuery, you can override the Kendo CSS class like below:
.k-list-container.k-state-border-up {
border-radius: 15px;
}
If the Kendo UI for Angular uses the same CSS class name, then the above should work.

Custom tooltip contents # ngx-charts | Angular2+ | TypeScript

I've been trying to set a custom label in a line chart's tooltip , e.g., modified number of minutes in HH:mm format (74 min --> 1:14), for quite some time now, but unfortunately without any success. Displaying the value as 1.283(...3) is not an alternative.
Number to HH:mm as tooltip label
Does anybody know how to preserve the x and y axis values (a date and a number respectively), and modify the tooltip display value?
For example: https://swimlane.github.io/ngx-charts/#/ngx-charts/line-chart
Instead of having a tooltip that displays Color, Country name and Number,
--> Color, Country name and String (Number > 3000 ? 'high' : 'low';)
Current behavior
Works as intended.
Expected behavior
To display custom labels.
Reproduction of the problem
Link in the description above
What is the motivation / use case for changing the behavior?
Being able to customize tooltips' contents
Please tell us about your environment:
OS: Win 10 x64, IDE: Eclipse EE
ngx-charts version: 3.0.2
Angular version: 6.0.2
Browser: [all]
Language: [TypeScript 2.3.3]
You can define your own tooltip templates and render any HTML you like in them:
<ngx-charts-line-chart
[scheme]="colorScheme"
[results]="multi" ...>
<ng-template #tooltipTemplate let-model="model">
This is the single point tooltip template
<pre>{{model|json}}</pre>
</ng-template>
<ng-template #seriesTooltipTemplate let-model="model">
This is vertical line tooltip template
<pre>{{model|json}}</pre>
</ng-template>
</ngx-charts-line-chart>
Example: https://swimlane.github.io/ngx-charts/#/ngx-charts/tooltip-templates
Code is here: https://github.com/swimlane/ngx-charts/blob/8ebb3dbcbbea443fefdcafd1f5c9069df0e0c4ae/src/app/app.component.html#L992-L998
The above solution does not work for multi-dimensional charts ( > 3) like Stacked Horizontal/Vertical Bar.
Another simple way which works for all cases is to add the tooltipText as an attribute as part of the model like below:
export let multi = [
{
name: 'Germany',
series: [
{
name: '2010',
value: 7300000,
tooltipText: 't1'
},
{
name: '2011',
value: 8940000,
tooltipText: 't2'
}
]
}
];
Then use the following code in markup,
<ngx-charts-bar-horizontal-stacked
[view]="view"
[scheme]="colorScheme"
[results]="multi"
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[legend]="showLegend"
[legendPosition]="legendPosition"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[xAxisLabel]="xAxisLabel"
[yAxisLabel]="yAxisLabel"
(select)="onSelect($event)">
<ng-template #tooltipTemplate let-model="model">
<div class="tooltip">
{{model.tooltipText}}
</div>
</ng-template>
</ngx-charts-bar-horizontal-stacked>
Thank you, once again. Didn't want to leave the issue unresolved.
The problem was the code snippet was inside a svg element.
Here's the final version:
<!-- This is single point tooltip template -->
<xhtml:ng-template #tooltipTemplate let-model="model">
<xhtml:div class="area-tooltip-container">
<xhtml:div *ngFor="let tooltipItem of model | json | durationHhmm" class="tooltip-item" style="text-align: center;">
<a style=" font-size: 1.2em;">{{tooltipItem.series}}</a><a *ngIf="tooltipShowTime==='DAY' || tooltipShowTime==='WEEK'" style=" font-size: 1.2em;"><br />{{tooltipItem.name | date: 'HH:mm'}} Uhr</a><a *ngIf="tooltipShowTime!=='DAY' && tooltipShowTime!=='WEEK'" style=" font-size: 1.3em; font-weight: 600;"><br />·</a><br /><a style=" font-size: 1.2em; font-weight: 600;">{{tooltipItem.name | date: 'dd.MM.yyyy'}} · </a><a style=" font-size: 1.3em; font-weight: 600;">{{tooltipItem.value}}</a>
</xhtml:div>
</xhtml:div>
</xhtml:ng-template>
<!-- Datapoints Y-Axis -->
<svg:g *ngFor="let series of data">
<svg:g ngx-charts-circle-series
[xScale]="xScale"
[yScale]="yScale"
[colors]="colors"
[data]="series"
[scaleType]="scaleType"
[visibleValue]="hoveredVertical"
[activeEntries]="activeEntries"
[tooltipDisabled]="tooltipDisabled"
[tooltipTemplate]="tooltipTemplate"
(select)="onClick($event, series)"
(activate)="onActivate($event)"
(deactivate)="onDeactivate($event)"
/>
</svg:g>

css overflow with elements moved outside div, elements disappear

I have a form in a div where I brought submit buttons out of the div to another part of the screen. This works nicely. However, I want to lock that div down to a specific size and relative position and use overflow:auto so when it grows too big (the form has elements that are unhidden with checkboxes) the entire screen doesn't scroll, just the div. The problem is, as soon as I add the overflow style, the submit boxes I moved off the div are hidden. I assume this is because with overflow all elements are locked into that div and scroll bars allow you to access them, but in this case the elements are moved left:-500px and it doesn't even give me a scroll bar to scroll left to see them. Basic code follows:
<div class="div1">
<div class="div2">
<form>
<input type="submit" class="sub1" />
</form>
</div>
</div>`
CSS would be:
div.div1 {
position:relative;
width:1000px;
margin: 0 auto;
}
div.div2 {
width:500px;
height:500px;
position:absolute;
top:125px;
left:500px;
}
input[type=submit].sub1 {
position:absolute;
left: -500px;
}
So this works, but as soon as I change the div2 css to:
div.div2 {
width:500px;
height:500px;
position:absolute;
top:125px;
left:500px;
overflow:auto;
}
The submit button disappears.
My question: is there any way to get the scrollbar and keep the div2 container to 500px high without losing the elements outside the div?
If I understand correctly, you can move div2 within the form and leave the submit button outside of div2. That way, the submit button will always be visible and div2 can have overflow.
<div class="div1">
<form>
<div class="div2">
<!-- form fields go here -->
</div>
<input type="submit" class="sub1" />
</form>
</div>
Note: You'll likely need to adjust styles on the button, but I'm not entirely sure about your end goal.

Magento How do i add showcase etc label on products in a category

Hi guys...
know this will appear very novice like to some...but id like to know how i can add SHOWCASE or a stamp with any other name to a product in a category?
The thing is i want to add an image across the product image (preferably in the upper right corner), for a product that i can setup in the backend. The image across will have to be visible in the GRID display and also on the individual product page.
So i basically have TWO questions:-
Qs. Do i have to add a special attribute to the product in the backend for something of this kind to become possible? i guess, it may have to be something similar to NEW FROM this date to that date!!. Any guidance is highly appreciated...
and than Qs2. How do i actually call the across image in both the list.phtml and view.phtml??
I hope this makes sense!!
thanxs
You don't have to add a special attribute to the product, you could do it based on the 'Set Product as New from Date' and 'Set Product as New to Date'. You can do it with a boolean too though, just create an attribute with the Yes/No input type and add it to your default attribute set. Give it an attribute code of showcase.
In your template files (templates/catalog/product/list.phtml and templates/catalog/product/view/media.phtml if you want it on the product view page) you'd add in a piece of conditional code that added in an extra absolutely positioned element to the markup if the product was flagged as being a showcase product,
ie
<div class="product-image">
<?php if($_product->getShowcase()) { ?>
<div class="showcase"></div>
<?php } ?>
<?php
$_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
?>
</div>
and then you'd create css like the following to produce the wee icon in the top corner;
.products-grid .product-image {
position: relative;
display: block;
width: 244px;
height: 156px;
margin: 0 0 10px;
}
.showcase {
position: absolute;
right: 0;
top: 0;
width: 65px;
height: 66px;
display: block;
z-index: 2;
background: url(../images/showcase.png) no-repeat;
}
This is an example I did myself last week, so it uses my image sizes but you get the idea. Hope this helps.

Button image for sitecore marketer module

I want to change submit button of Web Forms for Marketers module with image in Sitecore.
Thank in advance
You can change the button by updating contents of the following file:
\sitecore modules\Web\Web Forms for Marketers\Control\SitecoreSimpleFormAscx.ascx
Replace
<wfm:FormSubmit ID="submit" runat="server" Class="scfSubmitButtonBorder"/>
with you own custom control (which can contain Image / LinkButton / whatever)
It sounds like you are trying to change the submit button into an <input type="image" />. I have not found a way to do this with WFFM. You can style the submit button, or you can export the form to ASCX and make the change to an image yourself.
You can do quite a bit with CSS styling of <input type="submit" />.
http://www.456bereastreet.com/lab/styling-form-controls-revisited/submit-button/
You can change the button style in Default.css.
Use background-image to add the image.
Below example use an image as background for the Submit button in WFFM:
.scfSubmitButtonBorder
{
background-image: url(/images/bg_button.png);
padding-left: 5px;
float: right;
margin-bottom: 10px;
}
.scfSubmitButtonBorder input
{
border: none;
padding: 0 5px 0 0;
color: white;
font: 14px/14px FrutigerRoman, Arial !important;
width: 100px;
height: 30px;
background-image: url(/images/bg_button.png);
background-position: right -30px;
background-color: transparent;
cursor: pointer;
}
I suppose you're talking about Web Forms for Marketers module, aren't you? It is not clear from your initial question...
Anyway, in Form designer you can select the submit button and you'll its properties on the left side. Among various properties, the very first is the edit box called "Button Name" . Put the desired text for the Submit button there.
Here's how I did it.
First, create a custom control:
namespace Sitecore.Custom.Controls
{
public class ImageSubmitButton : Sitecore.Form.Web.UI.Controls.SubmitButton
{
public string ImageUrl { get; set; }
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(ImageUrl) == false)
{
writer.AddAttribute("type", "image");
writer.AddAttribute("src", ResolveUrl(ImageUrl));
}
// This won't overwrite our explicit type="image"
base.AddAttributesToRender(writer);
}
}
}
Export the form as ASCX in sitecore, use the Developer Center to create a new Sublayout and copy the exported ASCX code into this file. First, register a new prefix
<%# Register TagPrefix="ctrl" Namespace="Sitecore.Custom.Controls" Assembly="<AssemblyName>" %>
Finally, change
<cc0:submitbutton runat="server" onclientclick="$scw.webform.lastSubmit = this.id;" text="Submit" validationgroup="..." cssclass="..." id="..." onclick="OnClick" >
</cc0:submitbutton>
to
<ctrl:ImageSubmitButton ImageUrl="~/imgs/button.png" runat="server" OnClientClick="$scw.webform.lastSubmit = this.id;"
Text="Submit" validationgroup="..." cssclass="..." id="..."
OnClick="OnClick"></ctrl:ImageSubmitButton>
Finally, replace the form in your item with the sublayout.

Resources