Sencha touch calendar swarmonline - refresh calendar event - extjs

I'm trying to work with a Sencha Touch calendar extension (http://www.sencha.com/forum/showthread.php?156351-Ext.ux.TouchCalendar) Here is an example of what im using: http://www.swarmonline.com/Ext.ux.TouchCalendar/examples/simple-events-list.html
Am facing a problem here. when the app loads first time the events dots are missing..but when I resize my browser window, suddenly some event call happens and dots become visible and also at the same time its duplicating..
Am using their Simple events plugin. This is my view structure
Ext.define('WinReo.view.EventListPanel', {
extend: 'Ext.Panel',
//xtype:'EventListPanel',
requires: [
'Ext.dataview.List',
'Ext.layout.Fit'
],
alias: 'widget.EventListPanel',
config: {
// title : 'Events List',
layout : 'fit',
store:'WinReo.store.Events'
},
initialize: function(){
var store = Ext.getStore('Events');
store.load({
callback: function(records, operation, success) {
// the operation object contains all of the details of the load operation
console.log(records);
},
scope: this
});
this.callParent(arguments);
this.setItems([
{
xclass : 'Ext.ux.TouchCalendarView',
itemId : 'calendarView',
//minDate : Ext.Date.add((new Date()), Ext.Date.DAY, -40),
//maxDate : Ext.Date.add((new Date()), Ext.Date.DAY, 55),
viewMode : 'month',
weekStart : 0,
value : new Date(),
eventStore : Ext.getStore('Events'),
plugins : [Ext.create('Ext.ux.TouchCalendarSimpleEvents')]
/* plugins : [Ext.create('Ext.ux.TouchCalendarEvents', {
eventBarTpl: '{Days2Go}'
})]*/
},
{
xtype : 'list',
itemId : 'calendarlist',
docked : 'bottom',
onItemDisclosure:'true',
cls:'myList',
height : 100,
itemTpl : ['<tpl if ="Days2Go==0">',
'<div class="calendarlistred"> <div style="float:left; width: 45%">{PropertyAddr}</div><div style="float:left; width:45%">{TaskDesc}</div><div style="float:right; width:10%">{Days2Go}</div></div>',
'</tpl>',
'<tpl if ="Days2Go!=0">',
'<div> <div style="float:left; width: 45%">{PropertyAddr}</div><div style="float:left; width:45%">{TaskDesc}</div><div style="float:left; width:10%">{Days2Go}</div></div>',
'</tpl>'
],
store : Ext.create('Ext.data.Store', {
model: 'WinReo.model.Event',
data: []
}),
listeners: {
itemtap: function(dw, index,record, item, e){
window.open('http://blr.amt.in:8081/CRM_API/TaskCalendar.ashx?all_tasks=-1');
}
}
},
{
xtype : 'label',
html: '<div> <div style="float:left; width: 45%">Property</div><div style="float:left; width:45%">Task Description</div><div style="float:right; width:10%">Days to go</div></div>',
layout:'hbox',
docked : 'bottom',
cls:'calendarlistheader'
}
]);
}
});
Also I want I come to know that there is function there in TouchCalendarSimpleEvents.js
refreshEvents: function(){
if (!this.disabled && this.calendar.getViewMode() !== ‘DAY’) {
var datesStore = this.calendar.getStore();
…..
how can i call this function in my periodchange controller event ?
onPeriodChange: function(view, minDate, maxDate, direction){
Ext.Ajax.setDefaultHeaders({
'session_id' : localStorage.getItem("session_id")
});
console.log('periodchange');
console.log(view);
console.log(minDate);
var monthstartdate = Ext.Date.format(minDate, 'm/d/Y');
var url = 'http://blr.amt.in:8081/CRM_API/TaskCalendar.ashx?';
var urlafter = url + 'monthstartdate='+ monthstartdate;
// proxy change
var group_store = Ext.getStore("Events");
group_store.getProxy().setUrl(urlafter);
group_store.load();
var storecount = group_store.getCount();
this.refreshEvents(); // ***here i want to call refresh function***
}
Your help is much appreciated.

Related

extjs 4.0 delegate to the parent node on mouse over

I wanted to to delegate the mouseover/mouseout event to my parent node.
Here in the below code when i roll over to the #mycontent > span.bannerContent, i should delegate my mouseover event to the parents child img#bannerImage.
How i can achieve using extjs
HTML code:
<div>
<img id="bannerImage" />
<div id="mycontent">
<span> my dummy content </span>
</div>
EXtJS code
items : [{
xtype: 'image',
id:'bannerview1',
src: 'images/homePage/banner-1.jpg',
height: 500,
width: 1240,
listeners: {
el: {
click: function(el,src) {
var link =src.src;
if(link.indexOf("banner-1.jpg")!= -1){
window.open("main");
}
}
}
}
},
{
xtype: 'box',
id:'label',
html: '<span class="bannerContent"></span> ',
listeners: {
**el: {
mouseover:function(){
},
mouseout:function(){
}**
}
}
}
]
Normally you can pass an event to any observable using relayEvent, but the problem is, that Ext.dom.Element is not observable (does not know fireEvent method). So either you can listen to mouse events on parent div, hook carousel also on box events or if you insist on relaying events, extend Ext.Img such that it fires mouseout and mouseover events itself (and not its 'el') and then hook your carousel on such events.
Ext.define('My.Img',{
extend: 'Ext.Img',
alias: 'widget.myimage',
initComponent: function(){
var me = this;
me.addEvents('mouseover','mouseout');
me.on('render',function(){
me.getEl().relayEvent('mouseover',me);
me.getEl().relayEvent('mouseout',me);
});
me.callParent();
}
});
var myImage = Ext.create('My.Img',{
id:'bannerview1',
height: 500,
width: 1240,
src: '/img/header_01.gif',
listeners: {
mouseover:function(e){
console.log('mouseover image');
},
mouseout:function(e){
console.log('mouseout image');
}
}
});
Ext.create(' ... ',{
...
items : [ myImage,
{
xtype: 'box',
id:'label',
html: '<span class="bannerContent">blablabla</span> ',
listeners: {
render: function(){
this.getEl().relayEvent('mouseover',myImage);
this.getEl().relayEvent('mouseout',myImage);
}
}
}
]
});
Personally I think that such solution is not very straightforward.

Applying loadMask() to only grid pannel in extjs is not working

I want to apply load mask to only my grid pannel using id of it,
var myMask = new Ext.LoadMask({msg:"Please wait...",target:Ext.ComponentQuery.query('#grid')[0]});
myMask.show();
But this doesn't seems to work.The same code is working for tab pannel. Please suggest the necessary changes in order to achieve load mask only for grid pannel.
//View code
Ext.define("DummyApp.view.grid.GenericGrid",{
extend: "Ext.panel.Panel",
requires: ['DummyApp.view.toolBar','DummyApp.view.formPanel','Ext.state.*','Ext.data.*'],
controller: "genericGrid",
alias:"widget.genericgrid",
initComponent: function(){
Ext.apply(this, {
items: [this.createToolbar(),this.createGrid()]
});
this.callParent(arguments);
},
createToolbar: function(){
this.toolbar = Ext.create('DummyApp.view.toolBar');
return this.toolbar;
},
createGrid: function(){
this.grid = Ext.create('Ext.grid.Panel',{
itemId: 'batchGrid',
columnLines : true,
selType: 'cellmodel',
autoScroll :true,
maxHeight:535,
stateId: 'GridPanel',
loadMask: true,
stateful: true,
bind:{
store:'{genericGrid}'
}
});
return this.grid;
}
//Controller code
renderData: function(genericGrid) {
var store = Ext.create("DummyApp.store.GenericGrid"),
gridId = genericGrid.up().gridId,
serviceInput = Util.createServiceResponse(gridId);
var myMask = new Ext.LoadMask({msg:"Please wait...",target: Ext.ComponentQuery.query('#grid')[0]});
myMask.show();
Ext.Ajax.request({
url: Util.localGridService,
method: 'POST',
headers: Util.createRequestHeaders(),
jsonData: {
getConfigurationAndDataRequestType: serviceInput
},
success: function(conn, response, options, eOpts) {
myMask.hide();
var data = Util.decodeJSON(conn.responseText);
store.setData(Util.formatGridData(data));
genericGrid.reconfigure(store, Util.formatGridMetaData(data));
},
failure: function(conn, response, options, eOpts) {
myMask.hide();
Util.showErrorMsg(conn.responseText);
},
scope: this
});
store.load();
}
Look at this, in your code grid have itemId is "batchGrid"(find by "#batchGrid"), your grid panel have alias is "genericgrid"(find by "genericgrid" because it is alias of component). Then just correct it, replace your itemId on correct name, but better for this using needed component for target
var myMask = new Ext.LoadMask({msg:"Please wait...",target: Ext.ComponentQuery.query('#batchGrid')[0]});
better
renderData: function(genericGrid) {
var store = Ext.create("DummyApp.store.GenericGrid"),
grid = genericGrid.down('#batchGrid') // get grid
...
var myMask = new Ext.LoadMask({msg:"Please wait...", target: grid /*or genericGrid for gridpanel*/ });
Fiddle

ExtJs - Filter a grid with a search field in the column header

In ExtJs, there are many options to filter a grid. There are two nice examples in the documentation, like referenced in this question.
Remote filtering
Local filtering
However, having the filter hidden in the default dropdown menu of Ext.ux.grid.FiltersFeature looks really awkward for me. A good ergonomic choice would to create search fields in the column headers, like #Ctacus shows in his question.
How can this be achieved ?
After quite much research through the sparse documentation, and thanks to great questions and answers in SO, I came up with a simple class, that adds this functionality and and allows for configurations.
It looks like this:
You add this field in your grid like this:
Ext.define('Sandbox.view.OwnersGrid', {
extend: 'Ext.grid.Panel',
requires: ['Sandbox.view.SearchTrigger'],
alias: 'widget.ownersGrid',
store: 'Owners',
columns: [{
dataIndex: 'id',
width: 50,
text: 'ID'
}, {
dataIndex: 'name',
text: 'Name',
items:[{
xtype: 'searchtrigger',
autoSearch: true
}]
},
The following configs are possible, and work like described in the doc for Ext.util.Filter:
anyMatch
caseSensitive
exactMatch
operator
additionnaly you can use autoSearch. If true, the filter searches as you type, if false or not set, one has to click on the search icon to apply the filter.
ExtJs 5 / 6 Source:
Ext.define('Sandbox.view.SearchTrigger', {
extend: 'Ext.form.field.Text',
alias: 'widget.searchtrigger',
triggers:{
search: {
cls: 'x-form-search-trigger',
handler: function() {
this.setFilter(this.up().dataIndex, this.getValue())
}
},
clear: {
cls: 'x-form-clear-trigger',
handler: function() {
this.setValue('')
if(!this.autoSearch) this.setFilter(this.up().dataIndex, '')
}
}
},
setFilter: function(filterId, value){
var store = this.up('grid').getStore();
if(value){
store.removeFilter(filterId, false)
var filter = {id: filterId, property: filterId, value: value};
if(this.anyMatch) filter.anyMatch = this.anyMatch
if(this.caseSensitive) filter.caseSensitive = this.caseSensitive
if(this.exactMatch) filter.exactMatch = this.exactMatch
if(this.operator) filter.operator = this.operator
console.log(this.anyMatch, filter)
store.addFilter(filter)
} else {
store.filters.removeAtKey(filterId)
store.reload()
}
},
listeners: {
render: function(){
var me = this;
me.ownerCt.on('resize', function(){
me.setWidth(this.getEl().getWidth())
})
},
change: function() {
if(this.autoSearch) this.setFilter(this.up().dataIndex, this.getValue())
}
}
})
For ExtJs 6.2.0, the following bug and its workaround is relevant to this, else the column cannot be flexed.
ExtJs 4 Source:
Ext.define('Sandbox.view.SearchTrigger', {
extend: 'Ext.form.field.Trigger',
alias: 'widget.searchtrigger',
triggerCls: 'x-form-clear-trigger',
trigger2Cls: 'x-form-search-trigger',
onTriggerClick: function() {
this.setValue('')
this.setFilter(this.up().dataIndex, '')
},
onTrigger2Click: function() {
this.setFilter(this.up().dataIndex, this.getValue())
},
setFilter: function(filterId, value){
var store = this.up('grid').getStore();
if(value){
store.removeFilter(filterId, false)
var filter = {id: filterId, property: filterId, value: value};
if(this.anyMatch) filter.anyMatch = this.anyMatch
if(this.caseSensitive) filter.caseSensitive = this.caseSensitive
if(this.exactMatch) filter.exactMatch = this.exactMatch
if(this.operator) filter.operator = this.operator
console.log(this.anyMatch, filter)
store.addFilter(filter)
} else {
store.filters.removeAtKey(filterId)
store.reload()
}
},
listeners: {
render: function(){
var me = this;
me.ownerCt.on('resize', function(){
me.setWidth(this.getEl().getWidth())
})
},
change: function() {
if(this.autoSearch) this.setFilter(this.up().dataIndex, this.getValue())
}
}
})

Magnific popup and Backbone events: the view disappears when I add the magnific popup code

I'm trying to create an event to a view which opens a light box when I click in the tag, but when I add the magnific pop-up code the view disappears.
Here is my html code:
<section class="feed">
<script id="bookTemplate" type="text/template">
<div class="book">
<a href="<%= video %>" class="video">
<span><img src="img/go.png" class="go"></span>
<img src="<%= image %>"/>
<h2 class="bookTitle"><%= title %><h2>
</a>
</div>
</script>
</section>
And now my views and some data to test them:
var app = app || {};
app.BookListView = Backbone.View.extend({
el: '.feed',
initialize: function ( initialBooks ) {
this.collection = new app.BooksList (initialBooks);
this.render();
},
render: function() {
this.collection.each(function( item ){
this.renderBook( item );
}, this);
},
renderBook: function ( item ) {
var bookview = new app.BookView ({
model: item
})
this.$el.append( bookview.render().el );
}
});
app.BookView = Backbone.View.extend ({
tagName: 'div',
className: 'book',
template: _.template( $( '#bookTemplate' ).html()),
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
},
events: {
'click .video' : 'popUp'
},
popUp: {
function () {
$('.popup').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
}
}
});
$(function(){
var books = [
{title:'American Psycho', image:'http://2.bp.blogspot.com/ ytb9U3mZFaU/Ti2BcgQHuhI/AAAAAAAAAkM/NMyfgRIFgt0/s1600/american-psycho_44538679.jpg',
video:'http://www.youtube.com/watch?v=qoIvd3zzu4Y'},
{title:'The Informers',
image:'http://www.movieposterdb.com/posters/09_03/2008/865554/l_865554_d0038c1c.jpg',
video:'http://www.youtube.com/watch?v=g4Z29ugHpyk'}
];
new app.BooksListView (books);
I don't know if the problem is related with my views code or vith the magnific pop-up code.
Thanks
Looks like a syntax error
you have an extra set of braces which is not supposed to be present there.
Here popup is supposed to be a event handler and not a object hash
popUp: {
function () {
$('.popup').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
}
}
supposed to be
popUp: function (e) {
e.preventDefault();
$('.popup').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
}

ExtJS 3 multiple stateful grids (but with different stateIds)

I have my grid, which overwrites Ext.grid.GridPanel
I use this grid in 2 places on my site. I generate 2 different stateIds for them:
constructor:
TasksGrid.superclass.constructor.call(this, {
id: genId,
cls: 'tasks-grid',
border: false,
loadMask: {msg: 'Loading...'},
sm: sm,
stateful: true,
stateId: 'tasks-grid'+(config.booClientTab ? '-clients-tab' : ''), // depending on config.booClientTab I setup one or other stateId
...
this code I call in 2 places on site to create 2 grids:
this.TasksGrid = new TasksGrid(this, {
region: 'west',
split: true,
width: tasksGridWidth ? tasksGridWidth : defaultWidth,
booShowToolbar: true,
booClientTab: !empty(config.clientId) // if true, 1 stateId will be setup, false - other
});
But, when I test, state is applied only to first of 2 generated grids!! I checked cookies: seems, that all works fine: 2 cookies with 2 different names are created. But... State applies only to first call of "this.TasksGrid = new TasksGrid"!!!
ExtJS version: 3.0
Any thoughts?
I had the same problem. State can be applied to the component only during initialization not after initialization. Therefore it works for the first time but not after. Luckily you are using EextJs 3 and following piece of code worked for me in ExtJS 3 but not in 4. Basically when you apply new/other state to the grid just call
MyGrid = Ext.extend(Ext.grid.GridPanel,
{
/* #private */
constructor: function(config)
{
MyGrid.superclass.constructor.call(this, config);
},
initComponent: function()
{
var cfg =
{
border: true,
bodyBorder: false,
stateful: true,
stateId: 'grid',
tbar:
[{
text: 'View name'
},{
xtype: 'combo',
width: 80,
typeAhead: true,
triggerAction: 'all',
mode: 'local',
forceSelection: true,
hiddenName: 'stateId',
selectOnFocus:true,
displayField:'name',
ref: '../stateCombo',
valueField: 'id',
listeners:
{
scope: this,
change: function(combo, newValue, oldValue)
{
newValue = parseInt(newValue, 10); var grd = this;
grd.el.mask('Applying the view please wait');
var data = combo.store.data.items;
Ext.each(data, function(d)
{
d.data.id = parseInt(d.data.id, 10);
if(d.data.id === newValue)
{
Ext.util.Cookies.set('reportStateName', d.data.machineName);
grd.applyState(MyStateProvider.decodeState(d.data.value));
var conf = grd.getColumnModel().config;
grd.getColumnModel().setConfig(conf);
grd.doLayout();
grd.getView().updateAllColumnWidths();
grd.getView().refresh(true);
return;
}
});
grd.el.unmask();
grd = null;
}
},
store: new Ext.data.JsonStore
({
fields:
[{
name: 'id',
type: 'int'
}],
proxy : new Ext.data.HttpProxy
({
method: 'GET',
url: BASEURL + 'getsavedstate'
}),
idProperty: 'id'
})
}]
};
//we use applyIf for configuration attributes that should be left configurable
Ext.applyIf(this, cfg);
//ensure that any extra configurations that are set in initComponent method are applied to initialConfig:
Ext.applyIf(this.initialConfig, cfg);
/*
* Properties specified here are safe/protected from being overridden
* by an instance, so any 'private' default properties might be specified here.
*/
//some attributes we may want to keep unaltered, so we use Ext.apply non-alterable configurables
cfg =
{
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
stripeRows: true,
loadMask: true
};
Ext.apply(this, cfg);
//need this to work sometimes:
Ext.apply(this.initialConfig, cfg);
MyGrid.superclass.initComponent.apply(this, arguments);
this.on
({
afterrender: function(grid)
{
var grd = this;
this.stateCombo.getStore().load
({
callback: function(data, options, success)
{
grd.saveAsStateBtn.enable();
var applied = false;
var setStateValue = Ext.util.Cookies.get('reportStateName');
Ext.each(data, function(d)
{
//meaning no cookie was set so first time.
if(setStateValue === null)
{
if(d.data.machineName === 'default')
{
if(d.data.value !== '')
{
grd.applyState(MyStateProvider.decodeState(d.data.value));
applied = true;
grd.stateCombo.setValue(d.data.id);
return;
}
applied = true;
grd.stateCombo.setValue(d.data.id);//Here value should be fetched from cookie
return;
}
}
else//Cookie was set
{
if(d.data.machineName === setStateValue)
{
if(d.data.value !== '')
{
var s = MyStateProvider.decodeState(d.data.value);
grd.applyState(s);
applied = true;
grd.stateCombo.setValue(d.data.id);//Here value should be fetched from cookie
return;
}
else
{
return;
}
}
}
});
//grd.doLayout();
if(data.length !== 0)
{
grd.stateCombo.enable();
grd.saveStateBtn.enable();
}
var conf = grd.getColumnModel().config;
grd.getColumnModel().setConfig(conf);
grd.doLayout();
grd.getView().updateAllColumnWidths();
grd.getView().refresh(true);
grd.doLayout();
grd.el.unmask();
}
});
this.el.mask('Applying the saved view please wait');
},
scope: this
});
},
onRender: function (container, position)
{
MyGrid.superclass.onRender.apply(this, arguments);
var el = this.el;
var grd = this;
this.saveStateWindow = new MySaveStateWindow
({
grid: grd,
renderTo: el
});
},
// template method
/* #private */
initEvents: function()
{
MyGrid.superclass.initEvents.apply(this, arguments);
},
afterRender: function()
{
MyGrid.superclass.afterRender.apply(this, arguments);
},
// template method
/* #private */
beforeDestroy: function()
{
//Call parent
MyGrid.superclass.beforeDestroy.apply(this, arguments);
},
onDestroy: function()
{
this.saveStateWindow.destroy();
MyGrid.superclass.onDestroy.apply(this, arguments);
}
});

Resources