Skip to content

Instantly share code, notes, and snippets.

View rattanchauhan's full-sized avatar
🎯
Focusing

Rattan Chauhan rattanchauhan

🎯
Focusing
View GitHub Profile
@rattanchauhan
rattanchauhan / Sencha 4
Created October 7, 2016 07:21
Saving component state in LocalStorage in Sencha Architect
Create a function init under Application and add the below code to initialze a state provider to store states of different components
in the browser's local storage.
// initialize state provided for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
Add the below two configs to the component you want to save the state for.
{
@rattanchauhan
rattanchauhan / app.js
Last active November 6, 2016 12:45
Setting global default ajax timeout through Sencha Architect
Ext.data.proxy.Server.override ({
timeout: 300000
});
Ext.data.Connection.override({
withCredentials: false,
useDefaultXhrHeader: false,
disableCaching:false,
timeout: 300000
});
@rattanchauhan
rattanchauhan / app.js
Last active November 6, 2016 12:45
Adding global exception handler through Sencha Architect.
Ext.Ajax.on({
requestexception: function(dataconn, response, options) {
console.dir(dataconn);
console.dir(response);
console.dir(response.status);
if (response.status === 401) {
me.redirectTo('login');
}
}
});
@rattanchauhan
rattanchauhan / formatXml.js
Created November 10, 2016 06:12
Utility method to format an xml string
/*
* Utility method to format an xml string
* text : xml String
* step : no of spaces for indentation
*/
formatXml : function(text,step) {
function createShiftArr(step) {
var space = ' ';
if ( isNaN(parseInt(step)) ) { // argument is string
@rattanchauhan
rattanchauhan / app.js
Last active November 10, 2016 17:16
Adding a loading spinner at app startup in Sencha Architect
if(Ext.fly('initialLoader')){
Ext.fly('initialLoader').destroy();
}
@rattanchauhan
rattanchauhan / ViewController1.js
Last active November 14, 2016 13:23
Adding gmaps to extjs app
addGmap: function (googlemapcontainer, viewModel) {
var mapcontainer = googlemapcontainer.down('#mapcontainer');
googlemapcontainer.setHidden(true);
// remove old map
if(mapcontainer) {
mapcontainer.destroy();
}
// create new map
@rattanchauhan
rattanchauhan / Usage.js
Last active November 16, 2016 06:26
Capturing User details for re-using throughout a Sencha app
onMenuPanelRenderer : function() {
var hasWebRole = User.hasRole(Config.role.web);
var hasAdminRole = User.hasRole(Config.role.admin);
if (hasWebRole) {
// set mentu item visible true based on role
}
if (hasAdminRole) {
// set mentu item visible true based on role
@rattanchauhan
rattanchauhan / Java8.java
Last active November 24, 2016 17:14
Java8 features in practice
package com.practice.test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
@rattanchauhan
rattanchauhan / Application.js
Last active January 11, 2017 04:29
Saving Grid state in Extjs
Ext.application({
.
.
.
// init method
init: function() {
// initialize state provider for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
}
@rattanchauhan
rattanchauhan / Poller.js
Created May 30, 2017 13:11
Extjs Poller utility
Ext.define('Empty.common.Poller', {
singleton: true,
alternateClassName: ['Poller'],
/**
* Utility to poll an endpoint provided with the required parameters
* Mandatory parameters are : params.pollInterval, params.pollTimeout, params.success
* @params {Object} params
*