auto_complete feature not using filter_plugin_options when using yadcf - yadcf

I am using the auto_complete feature in yadcf plugin. I want to set the minLength for it, but on setting it the option does not seem to reflect on the page.
Please have a look at my code
yadcf.init(table,
[{
column_number : 0,
filter_type : "auto_complete",
filter_container_id: "selName",
filter_default_label : "Type Name",
cumulative_filtering : true,
filter_reset_button_text : "",
reset_button_style_class : "searchicon glyphicon glyphicon-remove-circle",
filter_match_mode : "startsWith",
filter_plugin_options :{
minLength : 3
}
});
can you please let me know what I have missed and what changes I need to do?

Related

Mongodb query problem, how to get the matching items of the $or operator

Thank you for first.
MongoDB Version:4.2.11
I have a piece of data like this:
{
"name":...,
...
"administration" : [
{"name":...,"job":...},
{"name":...,"job":...}
],
"shareholder" : [
{"name":...,"proportion":...},
{"name":...,"proportion":...},
]
}
I want to match some specified data through regular expressions:
For a example:
db.collection.aggregate([
{"$match" :
{
"$or" :
[
{"name" : {"$regex": "Keyword"}}
{"administration.name": {"$regex": "Keyword"}},
{"shareholder.name": {"$regex": "Keyword"}},
]
}
},
])
I want to set a flag when the $or operator successfully matches any condition, which is represented by a custom field, for example:{"name" : {"$regex": "Keyword"}}Execute on success:
{"$project" :
{
"_id":false,
"name" : true,
"__regex_type__" : "name"
}
},
{"administration.name" : {"$regex": "Keyword"}}Execute on success:"__regex_type__" : "administration.name"
I try do this:
{"$project" :
{
"_id":false,
"name" : true,
"__regex_type__" :
{
"$switch":
{
"branches":
[
{"case": {"$regexMatch":{"input":"$name","regex": "Keyword"}},"then" : "name"},
{"case": {"$regexMatch":{"input":"$administration.name","regex": "Keyword"}},"then" : "administration.name"},
{"case": {"$regexMatch":{"input":"$shareholder.name","regex": "Keyword"}},"then" : "shareholder.name"},
],
"default" : "Other matches"
}
}
}
},
But $regexMatch cannot match the array,I tried to use $unwind again, but returned the number of many array members, which did not meet my starting point.
I want to implement the same function as mysql this SQL statement in mongodb, like this:
SELECT name,administration.name,shareholder.name,(
CASE
WHEN name REGEXP("Keyword") THEN "name"
WHEN administration.name REGEXP("Keyword") THEN "administration.name"
WHEN shareholder.name REGEXP("Keyword") THEN "shareholder.name"
END
)AS __regex_type__ FROM db.mytable WHERE
name REGEXP("Keyword") OR
shareholder.name REGEXP("Keyword") OR
administration.name REGEXP("Keyword");
Maybe this method is stupid, but I don’t have a better solution.
If you have a better solution, I would appreciate it!!!
Thank you!!!
Since $regexMatch does not handle arrays, use $filter to filter individual array elements with $regexMatch, then use $size to see how many elements matched.
[{"$match"=>{"$or"=>[{"a"=>"test"}, {"arr.a"=>"test"}]}},
{"$project"=>
{"a"=>1,
"arr"=>1,
"src"=>
{"$switch"=>
{"branches"=>
[{"case"=>{"$regexMatch"=>{"input"=>"$a", "regex"=>"test"}},
"then"=>"a"},
{"case"=>
{"$gte"=>
[{"$size"=>
{"$filter"=>
{"input"=>"$arr.a",
"cond"=>
{"$regexMatch"=>{"input"=>"$$this", "regex"=>"test"}}}}},
1]},
"then"=>"arr.a"}],
"default"=>"def"}}}}]
[{"_id"=>BSON::ObjectId('5ffb2df748966813f82f15ad'), "a"=>"test", "src"=>"a"},
{"_id"=>BSON::ObjectId('5ffb2df748966813f82f15ae'),
"arr"=>[{"a"=>"test"}],
"src"=>"arr.a"}]

What is the role of `slotShared attribute?

For what is the slotShared attribute on each slot in the pages request response used for?
{
"slotId" : "FooterSlot",
"slotUuid" : "eyJpdGV",
"position" : "Footer",
"name" : "Footer",
"slotShared" : true,
"components" : {
"component" : [ {} ]
}
slotShared tells you if the slot is shared by multiple pages. For example, a slot for a header or a logo could be shared/used by different pages.

$in query with $elemMatch in mongoDB

I need to find a document where "components" not exist OR if exists, its id is 1111 and isActive is true and "issues" not exist OR its id is 1111 and isActive is true.
Example:
Document 1: ////this contains "components" but not "issues"
{..
"components" : [
{
"id" : "1111",
"name" : "component1",
"isActive" : true
}
],
}
Document 2://this contains "issues" but not "components"
{..
"issues" : [
{
"id" : "1111",
"name" : "issue 1",
"isActive" : true
}
],
..}
Document 3://This is not having both
Query:
db.sample.find({
"issues":{$in:[null, {"$elemMatch" : {"id":"1111","isActive": {"$in":[true,null]}}}]},
"components":{$in:[null, {"$elemMatch" : {"id":"1111","isActive": {"$in":[true,null]}}}]}
})
But I am getting an error, "errmsg" : "cannot nest $ under $in",
Please help to form the query that returns all the above 3 documents.
You don't require $in. You need $or operator.
Try
db.sample.find({
$or:[
{"issues":{$exists:true,"$elemMatch" : {"id":"1111","isActive": true}}},
{"components":{$exists:true,"$elemMatch" : {"id":"1111","isActive": true}}}
]
})
Based on OP's comments. here is the working version.
db.Sample.find({
$or:[
{"issues":{$exists:true,"$elemMatch":{"id":"1111","isActive":true}},
"components":{$exists:false} },
{"components":{$exists:true,"$elemMatch":{"id":"1111","isActive":true}},
"issues":{$exists:false}},
{"issues":{$exists:true,"$elemMatch":{"id":"1111","isActive": true}},
"components":{$exists:true,"$elemMatch":{"id":"1111","isActive":true}}},
{"issues":{$exists:false}, "components":{$exists:false}}
]
})

Trying to create a yadcf filter for a column with images

I need to create a filter on a tipical columns created with images: each field is an image with this format:
<img src='http://lab.onclud.com/psm/blackcircle.png' class='notasg'>
I've created a fiddle example here: fiddle
An explication:
there are only 2 diferents status: [assigned/not assigned] although there are 4 diferents images (black, red, yellow and green).
Only black image correspond to not assigned status. The others three ones (red, yellow and green) correspond to assigned status.
As you could see, I've tried to differentiate those status by class HTML tag in img elements (notasg/asgn).
Thanks in advance.
PD:
I'm getting data from a json, so I can't put:
<td data-search="notassigned">
directly on HTML code. As a solution, I've used createdCell (columnDefs option) as you could see on the next updated to create data-search attribute on td element fiddle.
In this one, as you could test, your previously created filter doesn't work. I've tried some solutions, but no one has worked.
Please help me again on this one. Thanks in advance.
You can make use of the datatables HTML5 data-* attributes, and then tell yadcf to rely on this dt feature with the use of html5_data
So your td will look something like
<td data-search="assigned"><img src='http://lab.onclud.com/psm/redcircle.png' class='asgn'></td>
and yadcf init will look like
var oTable = $('#example').DataTable();
yadcf.init(oTable, [
{
column_number: 0,
html5_data: 'data-search',
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}]);
Notice that I used filter_match_mode: 'exact', because I used data-search="notassigned" and data-search="assigned", and since the assigned word included inside notassigned I had to tell yadcf to perform an exact search, this can be avoided if you will use unique search term in your data-search= attribute,
See working jsfiddle
Another solution as introduced by kthorngren from datatables forum is to use the following dt init code
var oTable = $('#example').DataTable({
columnDefs: [{
targets: 0,
render: function(data, type, full, meta) {
if (type === 'filter') {
return full[0].search('asgn') >=1 ? "assigned" : full[0].search('notasg') >= 1 ? "notassigned" : data
} else {
return data
}
}
}],
});
and yadcf init (removed html5_data)
yadcf.init(oTable, [
{
column_number: 0,
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}
]);
third option - look here

dijit/form/FilteringSelect not working in phone

i have a drop down using dijit/form/FilteringSelect which is not supporting in mobile but it is working on web. i need my drop down to work in both web and mobile.can any one help
require(
[ "dojo/store/Memory", "dijit/form/FilteringSelect", "dojo/domReady!"],
function(Memory, FilteringSelect) {
var filteringSelect = new FilteringSelect({
id : "statusList",
value : "id",
style : "width: 150px;",
maxLength: "50",
placeHolder : "-- select one --",
displayedValue : defaultStatus,
onChange : setStatusId,
store : dataStore,
}, "statusList");
filteringSelect.startup();
});
You should have a look to dojox/mobile/SearchBox widget.
It'll do the same job than dijit/form/FilteringSelect with approximately the same configuration (You can pass to it the same datastore).