Related
In KendoJqueryTreelist, when filter data using Contains then duplicate record is not show
In KendoJqueryTreelist, when filter data using Contains then duplicate record is not show, But i require to show all record that contains(Including duplicate record) in kendo jquery treelist. filter by last name
"<script>
$("#treeList1").kendoTreeList({
columns: [
"lastName",
"position"
],
filterable: true,
dataSource: {
data: [
{ id: 1, parentId: null, lastName: "Jackson", position: "CEO" },
{ id: 2, parentId: 1, lastName: "Weber", position: " VP, Engineering" },
{ id: 1, parentId: null, lastName: "Jackson", position: "CEO" },
{ id: 4, parentId: 1, lastName: "Weber", position: " VP, Engineering" }
]
}
});
</script>"
Telerik/Kendo never likes to have duplicate id's breaks almost all of their components, I would on the server side generate a unique id for every row and add a new column if "employee-id" is used:
$("#treeList1").kendoTreeList({
columns: [
"lastName",
"position"
],
filterable: true,
dataSource: {
data: [
{ id:1, employeeId: 1, parentId: null, lastName: "Jackson", position: "CEO" },
{ id:2, employeeId: 2, parentId: 1, lastName: "Weber", position: " VP, Engineering" },
{ id:3, employeeId: 1, parentId: null, lastName: "Jackson", position: "CEO" },
{ id:4, employeeId: 4, parentId: 1, lastName: "Weber", position: " VP, Engineering" }
]
}
});
</script>"
I have this TKEntityProperty:
<TKEntityProperty v-tkDataFormProperty name="groups" displayName="Groups" index="2" :valuesProvider="retrieveGroups">
and this gets values from below object:
retrieveGroups:[
{key: "1", "label": "Group 1"},
{key: "2", "label": "Group 2"},
{key: "3", "label": "Group 3"}
]
but it does not multi select. I want to select multiple elements.
Is there another type of editor available ?
As #Manoj suggested, you should use AutoCompleteInline
Here is an example, it is available at Nativescript github page
data() {
return {
title: description,
booking: new Booking(),
bookingMetadata: {
'isReadOnly': false,
'commitMode': DataFormCommitMode.Immediate,
'validationMode': DataFormValidationMode.Immediate,
'propertyAnnotations': [{
'name': 'from',
'displayName': 'From:',
'index': 0,
'editor': DataFormEditorType.AutoCompleteInline,
'editorParams': {
'autoCompleteDisplayMode': AutoCompleteDisplayMode.Tokens
},
'valuesProvider': fromProviders,
},
{
'name': 'to',
'displayName': 'To:',
'index': 1,
'editor': DataFormEditorType.AutoCompleteInline,
'editorParams': {
'autoCompleteDisplayMode': AutoCompleteDisplayMode.Plain
},
'valuesProvider': ['New York', 'Washington', 'Los Angeles'],
},
]
}
};
},
(Sorry for my English. It will be great if you correct my mistakes).
I have a list of products and create product / edit product pages.
Each product has a set of attributes.
Each set of attributes has attributes.
How to do next:
When i choose a set of attributes for product at creating or at editing, in the form (create product / edit product) will be added new TextInputs with labels of attributes.
Here is my products:
products: [
{
id: 1,
title: 'title1',
description: 'description1',
shortDescription: 'shortDescription1',
seo: {
title: 'seotitle1',
description: 'description1',
keywords: ['keywords1'],
},
price: 428,
parentCategories: [1],
images: [
{
id: 123,
url: 'urlImage1',
title: 'urlTitle1',
},
],
isItActive: true,
creationDate: '2008-04-01T14:57:42.105Z',
modificationDate: '2009-04-01T14:57:42.105Z',
setOfAttributes: 1,
}, {
id: 2,
title: 'title2',
description: 'description2',
shortDescription: 'shortDescription2',
seo: {
title: 'seotitle2',
description: 'description2',
keywords: ['keywords2'],
},
price: 418,
parentCategories: [2],
images: [
{
id: 122,
url: 'urlImage2',
title: 'urlTitle2',
},
],
isItActive: false,
creationDate: '2010-04-01T14:57:42.105Z',
modificationDate: '2011-04-01T14:57:42.105Z',
setOfAttributes: 3,
}, {
id: 3,
title: 'title3',
description: 'description3',
shortDescription: 'shortDescription3',
seo: {
title: 'seotitle3',
description: 'description3',
keywords: ['keywords3'],
},
price: 423,
parentCategories: [3],
images: [
{
id: 323,
url: 'urlImage3',
title: 'urlTitle3',
},
],
isItActive: true,
creationDate: '2012-04-01T14:57:42.105Z',
modificationDate: '2013-04-01T14:57:42.105Z',
setOfAttributes: 2,
},
],
Here is my attrubutes:
attributes: [
{
id: 1,
name: 'asdgsd',
title: 'qwed',
type: 'список',
showInFilter: null,
},
{
id: 2,
name: 'zxcv',
title: 'fkf',
type: 'текстовое поле',
showInFilter: null,
},
{
id: 3,
name: 'asdkd',
title: 'rczh',
type: null,
showInFilter: null,
},
],
Here is a set of attributes:
setOfAttributes: [
{
id: 1,
title: 'Набор 1',
attributes: [1, 3],
},
{
id: 2,
title: 'Набор 2',
attributes: [3, 1, 2],
},
{
id: 3,
title: 'Набор 3',
attributes: [2, 3],
},
],
I was able to do just that(productsEdit.jsx):
<ReferenceField source="setOfAttributes" reference="setOfAttributes" linkType={false}>
<ReferenceArrayField source="attributes" reference="attributes">
<SingleFieldList>
<ChipField source="title" />
</SingleFieldList>
</ReferenceArrayField>
</ReferenceField>
Just a brief question.
u.quizzes.group_by(&:section_id)
Return me
{1=>
[#<Quiz id: 263, user_id: 2, exam_or_section: "section", section_id: 1>,
#<Quiz id: 264, user_id: 2, exam_or_section: "section", section_id: 1>,
#<Quiz id: 265, user_id: 2, exam_or_section: "section", section_id: 1>,
#<Quiz id: 266, user_id: 2, exam_or_section: "section", section_id: 1>,
#<Quiz id: 267, user_id: 2, exam_or_section: "section", section_id: 1>,
#<Quiz id: 268, user_id: 2, exam_or_section: "section", section_id: 1>],
2=>[#<Quiz id: 269, user_id: 2, exam_or_section: "section", section_id: 2>],
3=>[#<Quiz id: 270, user_id: 2, exam_or_section: "section", section_id: 3>]}
Is there an easy way to get the ids array instead of objects?
{1=> [263,264,265, 266, 267, 268], 2=>[269], 3=> [270]}
Thank you
u.quizzes.select(:id, :section_id).group_by(&:section_id).each {|k, v| v.map!(&:id) }
The select is not strictly required but should be used, because the other fields arent used in any way and you would transfer useless data between the database and rails.
You could use map:
u.quizzes.group_by(&:section_id).map { |item|
[item.first, item.last.map { |q| q.id } ]
}.to_h
Hope it helps.
This will do it quite nicely.
u.quizzes.reduce({}) { |hash, quiz|
hash[quiz.section_id] = Array(hash[quiz.section_id]) << quiz.id
hash
}
And as p11y recommended each_with_object.
u.quizzes.each_with_object({}) { |quiz, hash|
hash[quiz.section_id] = Array(hash[quiz.section_id]) << quiz.id
}
I have a collection of products which belong to few users, (the system is with ElasicSearch(ES), MySQL, Scala and ES Play Framework APIs link):
[
{ id: 1, user_id: 'jason', product: [...] },
{ id: 2, user_id: 'mike', product: [...] },
{ id: 3, user_id: 'mike', product: [...] },
{ id: 4, user_id: 'dan', product: [...] },
{ id: 5, user_id: 'bill', product: [...] },
{ id: 6, user_id: 'mike', product: [...] },
{ id: 7, user_id: 'dan', product: [...] },
{ id: 8, user_id: 'bill', product: [...] },
{ id: 9, user_id: 'mike', product: [...] },
{ id: 10, user_id: 'dan', product: [...] },
{ id: 11, user_id: 'bill', product: [...] },
...
]
I'd like to retrieve some certain number (for example, top 2 with highest matching score) products of best matching document based upon the user's id:
[
{ id: 2, user_id: 'mike', product: [...], _score: 100},
{ id: 3, user_id: 'mike', product: [...], _score: 95},
{ id: 4, user_id: 'dan', product: [...], _score: 90},
{ id: 5, user_id: 'bill', product: [...], _score: 80},
{ id: 7, user_id: 'dan', product: [...], _score: 70},
{ id: 8, user_id: 'bill', product: [...], _score: 65},
...
]
I tried term facets on user_id, but I cannot find equal number products for each user currently, for example,
[
{ id: 2, user_id: 'mike', product: [...], _score: 100},
{ id: 3, user_id: 'mike', product: [...], _score: 95},
{ id: 4, user_id: 'dan', product: [...], _score: 90},
{ id: 5, user_id: 'bill', product: [...], _score: 80},
{ id: 6, user_id: 'mike', product: [...], _score: 75},
...
]
Term facets pseudo code:
/** query type is com.github.cleverage.elasticsearch.ScalaHelpers.IndexResults[Product]
* filtered is matching requirement filter, i.e. including keyword "fashion"
* limit is the size of returned users with matching document, i.e. 10
* finalQuery return 5 unique users based on tmpQuery result with 10 users
* each user has 2 products finally
*/
tmpQuery = query.withBuilder(filtered).withSize(limit)
finalQuery = tmpQuery.addFacet(FacetBuilders.termsFacet("userId").field("user_id").size(5))
How to ensure everyone has 2 products, rather than mike has 3, dan has 1 and bill has 1?
I mean, addFacet doesn't work now because finalQuery is based on tmpQuery, and tmpQuery returns 10 results which are more from mike due to higher matching score, how to update tmpQuery to reach the limitation of 2?)
Term facet cannot ensure unique users, it only return most frequent users. Actually, in this case, have to match products first, then retrieve its user_id then, so it cannot get users first and then their products.
Appreciate.