Does Kendo UI DropDownList support grouping? - kendo-ui

I'm using Kendo UI DropDownList but cannot find a way to group values in it. is this feature available?
saw the following post from early 2013 which says that this was on the roadmap, but not sure if it was implemented or not.
http://www.telerik.com/forums/option-group-for-datasource-in-dropdownlist

As of the Q1 2015 release, this is supported on the datasource. It doesn't look like you can do this when binding to local data though.
UserVoice Item
Demo

Grouping actually is supported now, in conjunction with the datasource. Here is a code snippet that will create a dropdown list using Kendo UI 2015.3.1111 and jQuery 1.9.1, grouping by team colors. The datasource, candidates, is a local array of data items. The dropdown list will replace an HTML element on the page, <input id="victim"/>.
var candidates = [
{ "id": 1, "name": "Alice", "team": "Red" },
{ "id": 2, "name": "Bob", "team": "Red" },
{ "id": 3, "name": "Charlie", "team": "Blue" },
{ "id": 4, "name": "Dorothy", "team": "Blue" },
{ "id": 5, "name": "Ed", "team": "Green" },
{ "id": 6, "name": "Frances", "team": "Green" },
{ "id": 7, "name": "George", "team": "Purple" },
{ "id": 8, "name": "Helen", "team": "Purple" },
];
$("#victim").kendoDropDownList({
"dataTextField": "name",
"dataValueField": "id",
"dataSource": { "data": candidates, "group": "team" },
"index": 0
});
This is what the dropdown looks like with stock styling in FireFox:
I hadn't noticed before, but the widget also orders the groups.

Grouping is not supported by the Kendo DropDownList widget.

Related

Magento 2 REST API : Product Price and Custom Attribute color are not reflecting in response

I am working on Magento2 [v2.4] Product integration use case.
I am creating a Product using REST API [postman] and observed that product price, color attributes are present in Request JSON but those are missing in Response received from Magento.
POST http://localhost/magento2/rest/V1/products
Request:
{
"product": {
"id": "2007",
"sku": "20210004",
"name": "Iphone 4",
"price": "400",
"status": 1,
"extension_attributes": {
"stock_item": {
"qty": 4,
"is_in_stock": "true"
}
},
"custom_attributes": [
{
"attribute_code": "color",
"value": 4
}
]
}
}
Response:
{
"id": 2007,
"sku": "20210004",
"name": "Iphone 4",
"attribute_set_id": 4,
"status": 1,
"visibility": 4,
"extension_attributes": {
"stock_item": {
"item_id": 18,
"product_id": 2007,
"stock_id": 1,
"qty": 4,
"is_in_stock": true,
"is_qty_decimal": false
}
},
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "url_key",
"value": "iphone-4"
}
]
}
If you look at the request and response payload, you will see that Price and Color are there in request but somehow Magento did not honor those and got missed in response.
If I want to make this work, I had to re-send same payload again. Then I could see Price and Color in response.
Could you please suggest what is the issue here?
This is down to a bug in Magento (https://github.com/magento/magento2/issues/13639).
At the time of writing this should be fixed in 2.4.3. For versions 2.4.2 and lower you can add the following to your payload:
"type_id": "simple"

Accomplish the select box Vuetify behavior into a text field

I want to accomplish the following, but using a textfield (v-text-field) input instead:
<v-select
:items="addresses"
label="Address Field"
item-value="id"
item-text="address_line1"
v-model="address_id"
>
</v-select>
The select box returns all the "address_line1" (item-text) values from the addresses array (:items) and the default selected value is the one that matches with address_id (v-model) in the zones array. The data comes from two arrays of objects, that are related and comes from two external API. I want a textfield with the related value, and because I want the user to be able to update the field freely.
zones: [
{
"id": 1,
"name": "Museum",
"description": "description",
"address_id": 1,
"branch_id": 1,
"parent_zone_id": 2,
"provider_id": 10
},
{
"id": 2,
"name": "Restaurant",
"description": "description",
"address_id": 2,
"branch_id": 1,
"parent_zone_id": 2,
"provider_id": 10
},
]
addresses: [
{
"id": 1,
"name": "Address Name",
"address_line1": "7210 Euismod Rd.",
"address_line2": null,
"address_line3": null,
"zip_code": "6301",
"city": "Some City",
"state_id": 3296,
"country_id": 238,
"latitude": "10.99710000",
"longitude": "63.91130000",
"user_id": 11
},
{
"id": 2,
"name": "Address Name 2",
"address_line1": "2110 Elmond St.",
"address_line2": null,
"address_line3": null,
"zip_code": "6301",
"city": "Some Other City",
"state_id": 3296,
"country_id": 238,
"latitude": "10.99710000",
"longitude": "63.91130000",
"user_id": 11
}
]
The only way I can think of, is by hidding the select box, which picks the value selected. And then ref the value to the input text field somehow.
In this use case, v-autocomplete might be useful for you. It allows you to type on the field freely and will actively search for the addresses as you type.
<v-autocomplete
:items="addresses"
label="Address Field"
item-value="id"
item-text="address_line1"
v-model="address_id"
></v-autocomplete>
Here's a sample demo.
Also, you might want to update your vuetify to the latest version (vuetify 2.3.10 as of now) because I have encountered problems in lower versions, specifically vuetify 2.0.1. The problem is that v-autocomplete's displayed text is not updating properly when you try to select an option that is equal to its v-model value. Fortunately, this is fixed in later versions.

Pagination in many-to-many mapping in Spring Boot

I have two tables with Many-To-Many mappings. Tables are content and tag. So, I have another table content_tag to normalize the many-to-many relationship. But, I am having problem in pagination. As example, when I am fetching a tag by name it returns a single tag object, but with multiple content object nested inside. I know how to do pagination for tag, but my question is how can I make pagination for the nested content object in a single tag object. Please see my result below, which I am getting from POSTMAN.
{
"id": 12,
"tag": "Viral",
"contents": [
{
"id": 15,
"idHide": "0",
"listCategory": {
"id": 11,
"title": "Dramai",
"titleBn": "ড্রামাই",
"status": "active"
},
"title": "Cat",
"titleBn": "#99",
"brief": "uytyyyy",
"briefBn": "#495",
"highlight": "0",
"dim": "0",
"sticky": "0",
"status": "active",
"createdAt": "Jan 24, 2018 3:08:34 PM",
"listTag": [
{
"id": 12,
"title": "Viral"
},
{
"id": 13,
"title": "Progress"
},
{
"id": 14,
"title": "Limit"
}
]
}
]
}
Please note contents tag in response is a list of content object for viral tag. Sometimes contents array size gone over 50 objects. So, I want to implement pagination for that. How can I implement pagination for content?

amcharts not rendering India map correctly in worldmap

While amcharts shows the India map correctly (showing the disputed regions as part of India) when displaying only India (http://jsfiddle.net/zxhseguw/5/)
"dataProvider": {
"map": "indiaLow",
"areas": [ {
"id": "IN-KA",
"value": 4447100,
}, {
"id": "IN-UP",
"value": 38763
}]
},
it shades it differently when rendering it on world map (http://jsfiddle.net/zxhseguw/6/)
"dataProvider": {
"map": "worldLow",
"areas": [ {
"id": "IN",
"value": 4447100,
}, {
"id": "AU",
"value": 387633
}]
},
I wonder, if there is a way to make it render India correctly, just like its possible in Google Charts by setting origin='India'
I'm assuming you're referring to the region around Kashmir, correct? Try using worldIndiaLow instead of worldLow, which includes more of that disputed area as part of India.
"dataProvider": {
"map": "worldIndiaLow",
"areas": [ {
"id": "IN",
"value": 4447100,
}, {
"id": "AU",
"value": 387633
}]
},
Updated fiddle

Custom object array binding?

I've looked through the documentation, but perhaps I've overlooked what I assume to be a straightforward task. Is it possible to provide a custom binding function so that, in an array of objects, each object corresponds to one cell, rather than each object corresponding to a full row? Would this binding maintain the reference to the original object so that the data would change after being modified in the spreadsheet?
For example, I'd want to create the following sheet:
With JSON in this structure:
[
{
"name": "USA",
"year": 2015,
"sales": 1,
},
{
"name": "USA",
"year": 2016,
"sales": 2,
},
{
"name": "USA",
"year": 2017,
"sales": 3,
},
{
"name": "Canada",
"year": 2015,
"sales": 4,
},
{
"name": "Canada",
"year": 2016,
"sales": 5,
},
{
"name": "Canada",
"year": 2017,
"sales": 6,
}
]
You should look at the columns definition. In there you can define the data source for each column such that it will iterate through your objects and set the values of each column given the id for that column. And yes, it uses references so if you edit them, your objects get edited as well.

Resources