Extjs bufferedStore infinite scroll not working to trigger Ajax calls - ajax

I have a buffered store that makes an ajax call. I have about 40 records in total. I want the multiple ajax calls to be triggered on scrolling the page. However, as soon as I load the page I see the multiple ajax calls being made even without scrolling. What change is needed to make this behavior happen only when I scroll the page(i.e, subsequent ajax calls made only on scrolling)? Any help would be great!
My buffered store is as below:
Ext.define('myStore', {
extend: 'Ext.data.BufferedStore',
requires: [
'myStoremodel' // model that the store takes in
],
storeId: 'myTeststore',
model: 'myStoremodel',
remoteSort: true,
buffered: true,
leadingBufferZone: 2,
trailingBufferZone: 2,
pageSize: 10,
proxy: {
type: 'ajax',
url: "/fetch/getNameList" // the API which returns data to load,
timeout: 5 * 60 * 1000,
reader: {
rootProperty: 'data.name',
totalProperty: 'data.recordSize'
},
simpleSortMode: true
}
});
The result of ajax call is as below:
The payload that gets sent is:
_dc: 1647375142598
page: 1
start: 0
limit: 10
The ajax call response:
{success: true, errorCode: 0, errorMsg: null,…}
data: {recordSize: 10, limit: 9,…}
name: [{id: 1234, name: "Jake_Mar142022", appId: 1, isClosed: null,…},…]
0: {id: 1234, name: "TimMar142022", appId: 1, isClosed: null,…}
1: {id: 1252, name: "RatMar142022", appId: null, isClosed: null,…}
2: {id: 1253, name: "MycahMar142022", appId: null, isClosed: null,…}
3: {id: 1238, name: "MeganMar142022", appId: null, isClosed: null,…}
4: {id: 1191, name: "MikeMar092022", appId: null, isClosed: null,…}
5: {id: 1271, name: "TomMar142022", appId: null, isClosed: null,…}
6: {id: 1211, name: "RamMar092022", appId: null, isClosed: null,…}
7: {id: 1212, name: "JustinMar092022", appId: 1, isClosed: null,…}
8: {id: 1213, name: "AnnieMar092022", appId: null, isClosed: null,…}
9: {id: 1231, name: "AnnMar142022", appId: null, isClosed: null,…}
limit: 9
recordSize: 41
errorCode: 0
errorMsg: null
success: true

You have multiple calls because extjs tries to grab as many data, as it needs to fill the visible grid PLUS 2.
If you can see 26, this would do 4 initial calls.
To get a single call you would need to set pageSize to 30.
I you want to have less calls you have to increase the pageSize in the proxy, which increases the limit.

Related

Vuetify - Don't trigger input on treeview when selection is synced

On the vuetify treeview component the #input event is triggered when the selected array is initialised, I don't want this behaviour, I need the input event to be triggered only when the user manually selects/deselects an item
<v-treeview
selectable
selected-color="red"
:value="selected"
:items="items"
#input="input"
></v-treeview>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
selected: [],
items: [
{
id: 1,
name: 'Applications :',
children: [
{ id: 2, name: 'Calendar : app' },
{ id: 3, name: 'Chrome : app' },
{ id: 4, name: 'Webstorm : app' },
],
},
{
id: 5,
name: 'Documents :',
children: [
{
id: 6,
name: 'vuetify :',
children: [
{
id: 7,
name: 'src :',
children: [
{ id: 8, name: 'index : ts' },
{ id: 9, name: 'bootstrap : ts' },
],
},
],
},
{
id: 10,
name: 'material2 :',
children: [
{
id: 11,
name: 'src :',
children: [
{ id: 12, name: 'v-btn : ts' },
{ id: 13, name: 'v-card : ts' },
{ id: 14, name: 'v-window : ts' },
],
},
],
},
],
},
{
id: 15,
name: 'Downloads :',
children: [
{ id: 16, name: 'October : pdf' },
{ id: 17, name: 'November : pdf' },
{ id: 18, name: 'Tutorial : html' },
],
},
{
id: 19,
name: 'Videos :',
children: [
{
id: 20,
name: 'Tutorials :',
children: [
{ id: 21, name: 'Basic layouts : mp4' },
{ id: 22, name: 'Advanced techniques : mp4' },
{ id: 23, name: 'All about app : dir' },
],
},
{ id: 24, name: 'Intro : mov' },
{ id: 25, name: 'Conference introduction : avi' },
],
},
],
}),
mounted() {
this.selected = [1]
},
methods: {
input() {
alert("input should not be triggered")// I don't want this to be triggered unless the user explicitly selects/deselects an item
}
}
})
Here is a codepen with the problem - https://codepen.io/amaieras/pen/yLPLyvZ?editors=1011
See that the alert is shown even if I don't trigger any selection, can I avoid this from happening?

CanvasJS labels are wrongly positioned

I'm using CanvasJS to display some weather data, but the labels seem to have the wrong position relative to their data point.
What is the cause of this?
This is my chart configuration:
animationEnabled: true,
exportEnabled: true,
title: {
text: 'Pronóstico 8 Días',
},
axisX: {
valueFormatString: 'DD MMM,YYYY',
labelAngle: -30,
labelPlacement: 'outside',
labelTextAlign: 'left',
},
axisY: {
title: 'Temperatura',
suffix: ' °C',
minimum: 18,
maximum: 40,
interval: 2,
},
data: [
{
name: 'Mínimas',
type: 'line',
yValueFormatString: '#0.## °C',
showInLegend: true,
indexLabelWrap: true,
indexLabelMaxWidth: 80,
dataPoints: min,
},
{
name: 'Máximas',
type: 'line',
yValueFormatString: '#0.## °C',
showInLegend: true,
indexLabelWrap: true,
indexLabelMaxWidth: 80,
dataPoints: max,
},
],
The issue was the dates were shifting because they included time, so I just turned into day/month/year only.

ReferenceField and ReferenceInput

(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>

Add reminder on google calendar with golang

I want to add a custom reminder to Google Calendar with golang:
event := &calendar.Event{
Summary: "Test GG calendar",
Location: "31 AAA",
Description: "Test google calendar",
Start: &calendar.EventDateTime{
DateTime: "2016-12-27T17:30:00+07:00",
TimeZone: "Asia/Ho_Chi_Minh",
},
End: &calendar.EventDateTime{
DateTime: "2016-12-27T17:40:00+07:00",
TimeZone: "Asia/Ho_Chi_Minh",
},
Reminders: &calendar.EventReminders{
Overrides: []*calendar.EventReminder{
{Method: "email", Minutes: 30},
{Method: "popup", Minutes: 10},
},
UseDefault: false,
},
}
When I run this code, google could not add event. I received this error: Unable to create event. googleapi: Error 400: Cannot specify both default reminders and overrides at the same time., cannotUseDefaultRemindersAndSpecifyOverride
Thanks
Based on my reading of google-apps/calendar/concepts/reminders, it seems that you should not specify the UseDefault: false, at the same time as setting the Overrides. Do not put the UseDefault: false, part, and it will be defaulting to false as its only required to set when wanting to remove overrides that are in place already.
So the expected code is:
event := &calendar.Event{
Summary: "Test GG calendar",
Location: "31 AAA",
Description: "Test google calendar",
Start: &calendar.EventDateTime{
DateTime: "2016-12-27T17:30:00+07:00",
TimeZone: "Asia/Ho_Chi_Minh",
},
End: &calendar.EventDateTime{
DateTime: "2016-12-27T17:40:00+07:00",
TimeZone: "Asia/Ho_Chi_Minh",
},
Reminders: &calendar.EventReminders{
Overrides: []*calendar.EventReminder{
{Method: "email", Minutes: 30},
{Method: "popup", Minutes: 10},
},
},
}
You should send ForceSendFields with UseDefault and set UseDefault to false
&calendar.EventReminders{
Overrides: []*calendar.EventReminder{
{
Method: "email",
Minutes: 12,
},
},
UseDefault: false,
ForceSendFields: []string{"UseDefault"},
}

backbone.js using external .json file as data source

I have a basic app http://jsfiddle.net/p3hpZ/ which uses data hardcoded in the script.js file like so:
//model data
var things = [
{ title: "Macbook Air", price: 799, id: 1 },
{ title: "Macbook Pro", price: 999, id: 2 },
{ title: "The new iPad", price: 399, id: 3 },
{ title: "Magic Mouse", price: 50, id: 4 },
{ title: "Cinema Display", price: 799, id: 5 }
];
I am trying to work out how to move the data into a seperate .json file. Here is what I have so far http://jsfiddle.net/wVsZh/

Resources