Skip to content

Instantly share code, notes, and snippets.

Rattan Chauhan rattanchauhan

Block or report user

Report or block rattanchauhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rattanchauhan
rattanchauhan / app.js
Last active Nov 6, 2016
AngularJs | Directive for Auto Focus Next element on Enter
View app.js
var app = angular.module("myApp", []);
app.directive("moveNextOnEnter", function() {
return {
restrict: "A",
link: function($scope, element) {
element.bind("keyup", function(e) {
if (e.which == 13) {
var $nextElement = element.next();
if($nextElement.length) {
$nextElement[0].focus();
@rattanchauhan
rattanchauhan / Sencha 4
Created Oct 7, 2016
Saving component state in LocalStorage in Sencha Architect
View Sencha 4
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 Nov 6, 2016
Setting global default ajax timeout through Sencha Architect
View app.js
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 Nov 6, 2016
Adding global exception handler through Sencha Architect.
View app.js
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 Nov 10, 2016
Utility method to format an xml string
View formatXml.js
/*
* 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 Nov 10, 2016
Adding a loading spinner at app startup in Sencha Architect
View app.js
if(Ext.fly('initialLoader')){
Ext.fly('initialLoader').destroy();
}
@rattanchauhan
rattanchauhan / ViewController1.js
Last active Nov 14, 2016
Adding gmaps to extjs app
View ViewController1.js
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 Nov 16, 2016
Capturing User details for re-using throughout a Sencha app
View Usage.js
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 Nov 24, 2016
Java8 features in practice
View Java8.java
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 Jan 11, 2017
Saving Grid state in Extjs
View Application.js
Ext.application({
.
.
.
// init method
init: function() {
// initialize state provider for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
}
You can’t perform that action at this time.