The filter doesnt work with one input character on b-table - bootstrap-vue

i have a b-table with a filter, but the filter doesn't work when i search by one character, in my case, by the ID, but, if i introduce 2 or more numbers this work.
i check the example on bootstrap-vue and this work searching by one number, but i cant find why in my code this not work as i expected.
<div id="app">
<span label-for="search">search: </span>
<input id="search" type="text" v-model="filter" placeholder="type by search">
{{ this.filter }}
<b-table
class="mt-2"
:filter="filter"
:fields="fields"
:items="items">
</b-table>
</div>
window.onload = () => {
new Vue({
el: '#app',
data() {
return {
filter: null,
fields: [
{
key: 'isoqf_id',
label: '#'
},
{
key: 'name',
label: 'Name'
},
{
key: 'references',
label: 'references id'
}
],
items: [
{
"isoqf_id": 1,
"cerqual": {
"explanation": "Suspendisse eget ligula blandit, dignissim neque at, luctus nunc. Nulla eros odio, fringilla et diam ut, maximus euismod nibh.",
"option": "0"
},
"name": "finding #1",
"references": ["4a5f2a", "4a5f2f"],
"organization": "7b9c88ec182ca383",
"project_id": "5d84d6bc2b711a1a2eba93ea",
"id": "5d84ee422b711a1a2eba9507",
"cerqual_option": "0"
}, {
"isoqf_id": 2,
"cerqual": {
"explanation": "",
"option": "0"
},
"name": "finding #2",
"references": ["4a5f3b", "4a5f37"],
"organization": "7b9c88ec182ca383",
"project_id": "5d84d6bc2b711a1a2eba93ea",
"id": "5d850b3c2b711a1a2eba956f",
"cerqual_option": "0"
}, {
"isoqf_id": 3,
"cerqual": {
"explanation": "",
"option": "3"
},
"name": "finding #3",
"references": ["4a5f3b", "4a5f28"],
"organization": "7b9c88ec182ca383",
"project_id": "5d84d6bc2b711a1a2eba93ea",
"id": "5d8517a72b711a1a2eba9679",
"cerqual_option": "3"
}]
}
},
methods: {
}
})
}
the url for test https://codepen.io/damian-garrido/pen/aboemNG
i expect i can search by the isoqf_id field, what i'm doing wrong?

The default search algorithm searches ALL fields in the items table (not just visible data). It matches by looking for anything that contains the filter string. So if you type in the digit 1 it will show all records that have the character 1 in any fields.
To limit to just certain fields, set the prop filter-included-fields to an array containing the top level property names (field names) that you want to restrict the search to. If you want to limit to just isoqf_id, then set :filter-included-fields=['isoqf_id']". To limit filtering to isoqf_id and references set `:filter-included-fields=['isoqf_id', 'references']"
See https://bootstrap-vue.js.org/docs/components/table#built-in-filtering-options

Related

POSTGRES jsonb document GIN Indexes are created on what all objects?

I am using Postgres DB 13.5. From pgdocs -
The technical difference between a jsonb_ops and a jsonb_path_ops GIN
index is that the former creates independent index items for each key
and value in the data, while the latter creates index items only for
each value in the data. Basically, each jsonb_path_ops index item
is a hash of the value and the key(s) leading to it; for example to
index {"foo": {"bar": "baz"}}
Understanding the above in detail is important for me coz my jdata (document) is big with many keys and nested objects. Consider my json data that is stored as jsonb in a column named jdata looks like below -
{
"supplier": {
"id": "3c67b6eb-3b0d-492d-8736-66df107b83b3",
"customer": {
"type": "pro",
"name": "John George",
"address": [
{
"add-id": "098ad4df-2a90-4fda-8f92-dbe8d7196732",
"addressActive": true,
"street": "abc street",
"zip": 94044,
"staying-since": "long long",
"accessibility": {
"traffic": "heavy/congested",
"bestwaytoreach": {
"weekdays": {
"bart/metro/calltrain": true,
"price": {
"off-peak-hours": "affordable",
"peak-hours": "high"
},
"journey-time": "super-fast"
}
},
"weekends": {
"byroad": {
"ok": true,
"distance": "long",
"has-tolls": {
"true": true,
"toll-price": "relatively-high"
},
"journey-speed": "fast"
}
}
}
},
{
"add-id": "ddd1d2a0-9050-4bcf-a3ad-2e608d65e468",
"addressActive": true,
"street": "xyz street",
"zip": 10001,
"staying-since": "moved recently",
"accessibility": {
"traffic": "heavy/congested",
"bestwaytoreach": {
"weekdays": {
"subway": true,
"price": {
"off-peak-hours": "affordable",
"peak-hours": "high"
},
"journey-speed": "super-fast"
}
},
"weekends": {
"byroad": {
"ok": true,
"distance": "moderate",
"tolls": {
"has-tolls": true,
"toll-price": "relatively-high"
},
"journey-time": "super-fast"
}
}
}
}
],
"firstName": "John",
"lastName": "CRAWFORD",
"emailAddresses": {
"personal": [
"johnreplies#jg.com",
"ursjohn#jg.com",
"1234#jg.com"
],
"official": [
{
"repies-in": "1 day",
"email": "jg#jg.com"
},
{
"check's regularly": true,
"repies-in": "1 Hour",
"email": "jg-watching#jg.com"
}
]
},
"cities": [
"NYC",
"LA",
"SF",
"DC"
],
"splCustFlag": null,
"isPerson": true,
"isEntity": false,
"allowEmailSolicit": "Y",
"allowPhoneSolicit": "Y",
"taxPayer": true,
"suffix": null,
"title": null,
"birthDate": "05/10/1993",
"loyaltyPrograms": null,
"phoneNumbers-summary": [
1234567890,
1234567899,
1234567898,
1234567897
],
"phoneNumbers": [
{
"description": null,
"extension": null,
"number": 1234567890,
"countryCode": null,
"type": "Business"
},
{
"description": null,
"extension": null,
"number": 1234567899,
"countryCode": null,
"type": "Home"
}
],
"data-privacy": {
"required": true,
"laws": [
"CCPA",
"GDPR"
]
}
}
}
}
Now if I create GIN jsonb_ops index for jdata column - I want to clarify what all keys and values will be part of index.
For example - "staying-since" is a key nested at below path and it's part of "address" array too. But it's still a key, thought nested deep in the document. So will it be part of the index.
{
"supplier": {
"customer": {
"address": [
{
"staying-since": "long long" ...
And similarly "long long" is a value of a deeply nested key. Will it also be indexed.
And if GIN jsonb_path_ops index is created for jdata column --
Will a hash of "long long" value along with the path that leads to it will also be indexed.
hash(
"supplier": {
"customer": {
"address":[{"staying-since": "long long"}]
}
}
)
will the above also gets index.
I am aware about the operators that are supported by the GIN index types and am aware about the usage of these operators -
jsonb_ops ? ?& ?| #> #? ##
jsonb_path_ops #> #? ##

How can I parse this json with a model in Dart?

I need to parse this json with a model, but i don't know how, can someone help me please?
{
"onboarding" : [
{
"image" : "assetsblablabla",
"title" : "Your favorite delivery",
"subtitle" : "We got over 200 afiliated commerces for you"
},
{
"image" : "assets sdidj",
"title" : "Lorem ipsum dolor sit amet",
"texto_2" : ":0"
},
{
"image" : "assets/uwu/owo",
"title" : "Service on demand",
"subtitle" : "Lorem ipsum dolor sit amet"
}
]
}
Define your model as ("TestModel" is the arbitrary name I have used),
class TestModel {
var onboarding;
TestModel.fromJson(Map json) {
this.onboarding = json['onboarding'];
}
}
Then parse it as,
Widget build(BuildContext context) {
var json = {
"onboarding": [
{
"image": "assetsblablabla",
"title": "Your favorite delivery",
"subtitle": "We got over 200 afiliated commerces for you"
},
{
"image": "assets sdidj",
"title": "Lorem ipsum dolor sit amet",
"texto_2": ":0"
},
{
"image": "assets/uwu/owo",
"title": "Service on demand",
"subtitle": "Lorem ipsum dolor sit amet"
}
]
};
var fromTheModel = new TestModel.fromJson(json);
return Text(fromTheModel.onboarding[0]['image']); //displays "assetsblablabla"
}
The last line is obviously an example. You can replace the index [0] as well as the ['image'] according to your specific cases.
Is this what you are looking for?

Show Facebook events with angular

I want to display events on my website.
I take events from facebook with this :
infos.service.ts :
getEvents(link: string): Observable<any>{
let id = link.split('facebook.com/')[1].split('?')[0];
console.log("id ------> ",id);
return this.http.get(`https://graph.facebook.com/${id}?fields=events{name}&access_token=`)
.map(events => events.json());
}
After in home.component.ts :
onChange(e: Event) {
let value = e.target['value'];
this.service.getEvents(value).subscribe(event => {
console.log('events: ', event);
})
this.service.getEvents(value).subscribe((data) => this.events=data);
}
}
And I use this in order to display :
<ul>
<li> {{ events | json}}</li>
</ul>
But it shows me that and I can't use *ngFor :
"events": { "data": [ { "name": "Qui veut partir à Ibiza avec la team Coke TV cet été ?", "id": "1039032149505674" }, { "name": "MoveMyCity #MoveLyon", "id": "891490744279264" }, { "name": "MoveMyCity #MoveToulouse", "id": "816021265181647" }, { "name": "MoveMyCity #MoveMontpellier", "id": "801781889934749" }, { "name": "MoveMyCity #MoveMarseille", "id": "1610198129252793" }, { "name": "MoveMyCity #MoveNantes", "id": "936652956376199" }, { "name": "MoveMyCity #MoveParis", "id": "1609074386008334" } ], "paging": { "cursors": { "before": "QVFIUmdUc21tQW80b0tzLVgtc3VtUHI5OFNxdlZAMaVUwZAW02R1JvbGs4ZAUVwTUpmbUNiSVJ5eTBHVXMwSkw4RkFQQWNzZA3o1eTgzN2hxUFVINnlzd1ZA1eE93", "after": "QVFIUjgtRUUwR29ud25QdlE2YmVhQ3BfZAXdsd1R2SDlqeWlaeEk5empwVlBWQ1VkOXFtUkF2VUVPQlhvMWlLaHdNZA2VXczBuQkpyc0o1V2dNQUdZAYjllVE1B" } } }, "id": "998589190158511" }
Thanks for ur help.
I would step into the JSON and extract the array:
return this.http.get('the url')
.map(events => events.json().events.data);
}
The component code would stay the same, then you can very well iterate your data:
<div *ngFor="let event of events">
{{event.name}}
</div>
If you do not want to extract only the array, but keep your code like it is, then you need to iterate like so:
<div *ngFor="let event of events.events.data">
{{event.name}}
</div>

sap.m.Table - Vertical Scrolling with Fixed Header

I have one table having lots of data. Now I want to scroll vertically with table header fixed. can I achieve this?
Here is my code:
onInit: function() {
var data = new JSONModel("Model/data.json");
this.getView().setModel(data);
var otable = this.getView().byId("PlaceIt");
otable.bindItems("/employees", new ColumnListItem({
cells: [
new Text({
text: "{name}"
}),
new Text({
text: "{Physics}"
}),
new Text({
text: "{Chemistry}"
}),
new Text({
text: "{Maths}"
}),
new Text({
text: "{English}"
})
]
}));
otable.setModel(data);
var oScrollContainer = new ScrollContainer({
height: "100px",
vertical: true,
focusable: true,
content: [oTableItems]
});
},
<Table id="PlaceIt">
<columns>
<Column>
<Text text="Student Name" />
</Column>
<Column>
<Text text="Physics" />
</Column>
<Column>
<Text text="Chemistry" />
</Column>
<Column>
<Text text="Maths" />
</Column>
<Column>
<Text text="English" />
</Column>
</columns>
<!-- ... -->
</Table>
I tried using sap.m.ScrollContainer control but I'm not getting anything.
Here is a demo.
As of v1.54, the property sticky is publicly available.
sticky
Defines the section of the sap.m.Table control that remains fixed at the top of the page during vertical scrolling as long as the table is in the viewport.
Once its value is set to "ColumnHeaders", the headers will stay fixed while scrolling.
Be aware that this feature is supported only by modern browsers.
Demo: https://jsbin.com/ticivew/edit?js,output
Property description
Other sticky optionsv1.56 - The syntax for assigning multiple values in XMLView looks as follows:
<Table sticky="HeaderToolbar,InfoToolbar,ColumnHeaders">
Not sure why you don't want to use sap.m.Table, but here's an example nonetheless:
sap.ui.controller("view1.initial", {
onInit : function(oEvent) {
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({
data : [
{
"col1": "at curabitur vestibulum",
"col2": "porttitor pharetra rutrum",
"col3": 93
},
{
"col1": "hendrerit dui fringilla",
"col2": "adipiscing suspendisse lorem",
"col3": 36
},
{
"col1": "placerat vel placerat",
"col2": "suspendisse quis sit",
"col3": 9
},
{
"col1": "sagittis at sed",
"col2": "malesuada aliquam sit",
"col3": 26
},
{
"col1": "donec donec sed",
"col2": "dui tempor nunc",
"col3": 38
},
{
"col1": "sed vitae fringilla",
"col2": "vestibulum pretium dolor",
"col3": 17
},
{
"col1": "scelerisque curabitur orci",
"col2": "sit sollicitudin amet",
"col3": 16
},
{
"col1": "libero lacus pulvinar",
"col2": "lorem velit elit",
"col3": 15
},
{
"col1": "convallis in at",
"col2": "fringilla sagittis magna",
"col3": 35
},
{
"col1": "dolor magna sed",
"col2": "at turpis tortor",
"col3": 3
},
{
"col1": "elit mi tortor",
"col2": "quis aenean turpis",
"col3": 32
},
{
"col1": "ipsum et magna",
"col2": "amet massa aliquam",
"col3": 59
},
{
"col1": "eget magna at",
"col2": "pharetra amet porta",
"col3": 69
},
{
"col1": "magna et scelerisque",
"col2": "aliquam vitae nullam",
"col3": 4
},
{
"col1": "velit etiam odio",
"col2": "lorem lacus magna",
"col3": 28
},
{
"col1": "at scelerisque lorem",
"col2": "facilisis odio dolor",
"col3": 4
},
{
"col1": "amet ipsum massa",
"col2": "sollicitudin sed tortor",
"col3": 54
},
{
"col1": "velit tincidunt massa",
"col2": "risus tortor massa",
"col3": 7
},
{
"col1": "id amet adipiscing",
"col2": "aliquam vitae adipiscing",
"col3": 94
},
{
"col1": "lorem massa lacus",
"col2": "malesuada ac sed",
"col3": 27
}
]
});
this.getView().setModel(oModel);
}
});
sap.ui.xmlview("main", {
viewContent: jQuery("#view1").html()
})
.placeAt("uiArea");
/* extra CSS classes here */
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.ui.commons"></script>
<div id="uiArea"></div>
<script id="view1" type="ui5/xmlview">
<mvc:View
controllerName="view1.initial"
xmlns="sap.ui.commons"
xmlns:l="sap.ui.commons.layout"
xmlns:t="sap.ui.table"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc" >
<t:Table rows="{/data}" visibleRowCount="5">
<t:columns>
<t:Column width="100px">
<t:label><Label text="col1" /></t:label>
<t:template><TextView text="{col1}" /></t:template>
</t:Column>
<t:Column width="100px">
<t:label><Label text="col2" /></t:label>
<t:template><TextView text="{col2}" /></t:template>
</t:Column>
</t:columns>
</t:Table>
</mvc:View>
</script>
You will need two tables.
First table will have only columns and second will contain items to be displayed with empty column headers.
Second table will be the content of ScrollContainer.
demo
To get your own example working, you have to use a ScrollContainer wrapped around the table with vertical="true" and height set to some value. And you need the attribute sticky="ColumnHeaders" on the table itself.
Here is the code from your JS Bin example modified to work:
jQuery.sap.require("sap.m.MessageToast");
// Controller definition
sap.ui.controller("local.controller", {
onInit: function() {
var data = [{
name: "asd",
amount: "100",
currency: "USD",
size: "L"
}, {
name: "asd",
amount: "800",
currency: "INR",
size: "XL"
}, {
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
},{
name: "asd",
amount: "454",
currency: "USD",
size: "S"
}];
var oModel = new sap.ui.model.json.JSONModel(data);
this.getView().setModel(oModel);
var table = this.getView().byId("tableid");
var mytemplate = new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
text: "{name}"
}), new sap.m.Text({
text: "{amount}"
}), new sap.m.Text({
text: "{currency}"
}), new sap.m.Text({
text: "{size}"
})
]
});
table.bindAggregation("items",{
path: "/",
template : mytemplate
});
}
});
// Instantiate the View, assign a model and display
var oView = sap.ui.xmlview({
viewContent: jQuery('#view1').html()
});
oView.placeAt('content');
<!DOCTYPE HTML>
<html>
<head>
<meta name="description" content="temp">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title></title>
<script id="sap-ui-bootstrap" type="text/javascript" src="https://sapui5.ap1.hana.ondemand.com/resources/sap-ui-cachebuster/sap-ui-core.js" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m" data-sap-ui-xx-bindingSyntax="complex">
</script>
<!-- XML-based view definition -->
<script id="view1" type="sapui5/xmlview">
<mvc:View controllerName="local.controller" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m">
<App>
<Page title="My View" id="page">
<ScrollContainer
height="200px"
vertical="true"
>
<Table id="tableid" sticky="ColumnHeaders">
<columns>
<Column>
<Text text="column1" />
</Column>
<Column>
<Text text="column2" />
</Column>
<Column>
<Text text="column3" />
</Column>
<Column>
<Text text="column4" />
</Column>
</columns>
</Table>
</ScrollContainer>
</Page>
</App>
</mvc:View>
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>

Kendo grid with declarative editor template

Hopefully someone can help me with this - I've been staring at this for 8 hours and can't seem to find a solution. I'm trying to implement a pretty simple Kendo UI MVVM grid. The grid just has a list of roles with an attached category. When you click edit, the grid should allow an inline edit and the category column should turn into a drop down - which is a template that is also bound to a field in the view model.
Here's my jsfiddle: http://jsfiddle.net/Icestorm0141/AT4XT/3/
The markup:
<script type="text/x-kendo-template" id="someTemplate">
<select class="form-control categories" data-auto-bind="false" data-value-field="CategoryId" data-text-field="Description" data-bind="source: categories"></select>
</script>
<div class="manage-roles">
<div data-role="grid"
data-scrollable="true"
data-editable="inline"
data-columns='[
{ "field" : "JobTitle", "width": 120, "title" : "Job Title Code" },
{ "field" : "Description" },
{ "field" : "Category", "template": "${Category}","editor" :kendo.template($("#someTemplate").html()) },
{"command": "edit"}]'
data-bind="source: roles"
style="height: 500px">
</div>
</div>
And the javascript:
var roleViewModel = kendo.observable({
categories: new kendo.data.DataSource({
data: [
{ "CategoryId": 1, "Description": "IT" },
{ "CategoryId": 2, "Description": "Billing" },
{ "CategoryId": 3, "Description": "HR" },
{ "CategoryId": 4, "Description": "Sales" },
{ "CategoryId": 5, "Description": "Field" },
{ "CategoryId": 10, "Description": "Stuff" },
{ "CategoryId": 11, "Description": "Unassigned" }
]
}),
roles: new kendo.data.DataSource({
data: [
{ "RoleId": 1, "JobTitle": "AADM1", "Description": "Administrative Assistant I", "Category": "Stuff", "CategoryId": 10 },
{ "RoleId": 2, "JobTitle": "AADM2", "Description": "Administrative Assistant II", "Category": null, "CategoryId": 0 },
{ "RoleId": 3, "JobTitle": "ACCIN", "Description": "Accounting Intern", "Category": null, "CategoryId": 0 },
{ "RoleId": 4, "JobTitle": "ACCSU", "Description": "Accounting Supervisor", "Category": null, "CategoryId": 0 }, { "RoleId": 5, "JobTitle": "ACCTC", "Description": "Accountant", "Category": null, "CategoryId": 0 }
]
})
});
kendo.bind($(".manage-roles"), roleViewModel);
I havent been able to figure out why the editor template is not binding the drop down. When I use the same markup for template rather than binding to the category name with ${Category}, it works for the template property. (For some reason this doesnt work in fiddle. But the exact same code works locally).
At this point I'll take any suggestions/approaches anything. I really wanted to use MVVM and not the .kendoGrid() syntax but I'll get over myself if it cannot be done. Anyone got any insight into whats going on with the editor template?
You can still build your grid using MVVM, but I think you have to make custom editors with a function call.
So instead of "editor" :kendo.template($("#someTemplate").html()), you just call a function.
edit: rolesViewModel.categoryEditor
See http://demos.kendoui.com/web/grid/editing-custom.html
See sample http://jsbin.com/UQaZaXO/1/edit