Skip to content

Commit d576b3f

Browse files
committed
Sync with Kendo UI Professional
1 parent 2a32849 commit d576b3f

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Position DropDownList Popup in PanelBar Content
3+
page_title: Position DropDownList Popup in PanelBar Content - Kendo UI for jQuery PanelBar
4+
description: "Learn how to position DropDownList popup in the content of the Kendo UI PanelBar for jQuery."
5+
slug: dropdownlist-popup-in-panelbar-content
6+
tags: panelbar, content, dropdownlist, popup
7+
component: panelbar
8+
type: how-to
9+
ticketid: 1594859
10+
res_type: kb
11+
---
12+
13+
## Environment
14+
15+
<table>
16+
<tr>
17+
<td>Product</td>
18+
<td>Progress® Kendo UI® PanelBar for jQuery</td>
19+
</tr>
20+
<tr>
21+
<td>Product</td>
22+
<td>Progress® Kendo UI® DropDownList for jQuery</td>
23+
</tr>
24+
</table>
25+
26+
## Description
27+
28+
How can I position a DropDownList popup in the content of the PanelBar?
29+
30+
## Solution
31+
32+
1. Wrap the element, from which the DropDownList is initialized, in a container.
33+
34+
```html
35+
<li><span id="ddl-container"><input type="text" id="ddl"/></span></li>
36+
```
37+
38+
2. Use the [`popup.appendTo`](/api/javascript/ui/dropdownlist/configuration/popup#popupappendto) option of the component, in order to configure the position of the popup to the container.
39+
40+
```js
41+
popup: {
42+
appendTo: $('#ddl-container')
43+
}
44+
```
45+
3. You may also need to configure the style of the `animation container` by setting its `top` and `left` position.
46+
47+
```css
48+
.k-animation-container{
49+
top: initial !important;
50+
left: initial !important;
51+
}
52+
```
53+
54+
The following example demonstrates the full implementation of the suggested approach:
55+
56+
```dojo
57+
<ul id="panelbar">
58+
<li>Item 1
59+
<ul>
60+
<li ><span id="ddl-container"><input type="text" id="ddl"/></span></li>
61+
<li>Sub Item 2</li>
62+
<li>Sub Item 3</li>
63+
</ul>
64+
</li>
65+
</ul>
66+
<script>
67+
$("#panelbar").kendoPanelBar();
68+
69+
$("#ddl").kendoDropDownList({
70+
dataSource: [
71+
{ name: "Apples" },
72+
{ name: "Oranges" }
73+
],
74+
dataTextField: "name",
75+
dataValueField: "name",
76+
popup: {
77+
appendTo: $('#ddl-container')
78+
}
79+
});
80+
81+
</script>
82+
<style>
83+
.k-animation-container{
84+
top: initial !important;
85+
left: initial !important;
86+
}
87+
</style>
88+
```
89+
90+
## See Also
91+
* [JavaScript API Reference of the PanelBar](/api/javascript/ui/panelbar)
92+
* [JavaScript API Reference of the DropDownList](/api/javascript/ui/dropdownlist)
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
title: Display Different Filter Editors Depending on Operators
3+
page_title: Display Different Editors Depending on Operators - Kendo UI for jQuery Filter
4+
description: "Learn how to display different editors depending on the operator in the Kendo UI Filter for jQuery."
5+
slug: filter-different-editor-depending-on-operators
6+
tags: filter, editor, operator
7+
component: filter
8+
type: how-to
9+
ticketid: 1616662
10+
res_type: kb
11+
---
12+
13+
14+
## Environment
15+
16+
<table>
17+
<tr>
18+
<td>Product</td>
19+
<td>Progress® Kendo UI® Filter for jQuery</td>
20+
</tr>
21+
</table>
22+
23+
## Description
24+
25+
How can I have different editors appear depending on the current operator of the Filter?
26+
27+
## Solution
28+
29+
1. Bind the [`change`](/api/javascript/ui/filter/events/change) event to the `filterModel` of the component and identify the exact `Filter expression` from its items.
30+
1. Find the `editor` of the expression, empty it and then append a new `input` element.
31+
1. Check for the current operator of the `Filter expression` and initialize the corresponding component for the editor in the input element you appended.
32+
33+
The following example demonstrates how to achieve the desired scenario:
34+
35+
```dojo
36+
<script src="../content/shared/js/products.js"></script>
37+
<div id="example">
38+
<div id="filter"></div>
39+
<br />
40+
<br />
41+
<br />
42+
43+
<script>
44+
$(document).ready(function () {
45+
var dataSource = new kendo.data.DataSource({
46+
pageSize: 20,
47+
data: products,
48+
autoSync: true,
49+
schema: {
50+
model: {
51+
id: "ProductID",
52+
fields: {
53+
ProductID: { editable: false, nullable: true },
54+
ProductName: { validation: { required: true } },
55+
Category: { defaultValue: { CategoryID: 1, CategoryName: "Beverages" } },
56+
UnitPrice: { type: "number", validation: { required: true, min: 1 } }
57+
}
58+
}
59+
}
60+
});
61+
62+
$("#filter").kendoFilter({
63+
dataSource: dataSource,
64+
expressionPreview: true,
65+
fields: [
66+
{ name: "ProductName", label: "Product Name" },
67+
{ name: "CategoryID", type: "number", label: "Category", defaultValue: 1, editorTemplate: categoryDropDownEditor },
68+
{ name: "UnitPrice", type: "number", label: "Unit Price", editorTemplate: unitPriceEditor },
69+
{ name: "UnitsInStock", type: "number", label: "Units In Stock" },
70+
{ name: "QuantityPerUnit", label: "Quantity Per Unit" },
71+
]
72+
});
73+
74+
$("#filter").data("kendoFilter").filterModel.bind("change", function(e) {
75+
if(!e.items) {
76+
return;
77+
}
78+
79+
let model = e.items[0];
80+
if(model.field == "ProductName") {
81+
82+
setTimeout(function(){
83+
var editorContainer = $("[id='"+model.uid+"']").find(".k-toolbar-item.k-filter-value");
84+
editorContainer.empty();
85+
let input = $("<input />")
86+
.appendTo(editorContainer);
87+
88+
if(model.operator == "eq" || model.operator == "neq") {
89+
input.kendoDropDownList({
90+
optionLabel: "Select value...",
91+
dataSource: ["1", "2"],
92+
value: model.value,
93+
change: function(e) {
94+
model.set("value", e.sender.value());
95+
}
96+
});
97+
98+
} else {
99+
input.kendoTextBox({
100+
value: model.value,
101+
change: function(e) {
102+
model.set("value", e.sender.value());
103+
}
104+
});
105+
}
106+
})
107+
108+
}
109+
})
110+
});
111+
112+
function unitPriceEditor(container, options) {
113+
$('<input data-bind="value: value" name="' + options.field + '"/>')
114+
.appendTo(container)
115+
.kendoNumericTextBox();
116+
}
117+
118+
function categoryDropDownEditor(container, options) {
119+
$('<input data-bind="value: value" name="' + options.field + '"/>')
120+
.appendTo(container)
121+
.kendoDropDownList({
122+
dataTextField: "CategoryName",
123+
dataValueField: "CategoryID",
124+
dataSource: {
125+
type: "odata",
126+
transport: {
127+
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Categories"
128+
}
129+
}
130+
});
131+
}
132+
</script>
133+
</div>
134+
```
135+
136+
## See Also
137+
* [JavaScript API Reference of the Filter](/api/javascript/ui/filter)

0 commit comments

Comments
 (0)