Discuss anything related to web development but no technical support questions


Post by xjpmauricio »

Hi, i'm using the scheduler with grouping, i've followed this example: http://ext-scheduler.com/examples/exter ... gdrop.html
...and created something of my own. My question is: how can i force a specific group to appear first or to be the first scheduler row? I've tried everything
from sorting, etc, but the row i want to change it's order keeps on appearing last. Any ideias?

Thanks.

Post by mats »

You want to modify the way the groups are ordered? This is a little tricky but doable. You'll need to override some of its methods, but it should be fairly straightforward I think.

Post by xjpmauricio »

mats wrote:You want to modify the way the groups are ordered? This is a little tricky but doable. You'll need to override some of its methods, but it should be fairly straightforward I think.
could you give some more clues?

Post by mats »

Search the Ext JS forums too, lots of great threads there. This one should provide some guidance: https://www.sencha.com/forum/showthread. ... d&p=287549

:)

Post by xjpmauricio »

mats wrote:Search the Ext JS forums too, lots of great threads there. This one should provide some guidance: https://www.sencha.com/forum/showthread. ... d&p=287549

:)
...once again...thanks for the quick tip; this code, might be inserted on the bottom of your js:
Ext.override(Ext.data.GroupingStore, {
	groupDir : 'ASC',
	groupBy : function(field, forceRegroup, direction){
		direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
		if(this.groupField == field && this.groupDir == direction && !forceRegroup){
			return;
		}
		this.groupField = field;
		this.groupDir = direction;
		if(this.remoteGroup){
			if(!this.baseParams){
				this.baseParams = {};
			}
			this.baseParams['groupBy'] = field;
			this.baseParams['groupDir'] = direction;
		}
		if(this.groupOnSort){
			this.sort(field, direction);
			return;
		}
		if(this.remoteGroup){
			this.reload();
		}else{
			var si = this.sortInfo || {};
			if(si.field != field || si.direction != direction){
				this.applySort();
			}else{
				this.sortData(field, direction);
			}
			this.fireEvent('datachanged', this);
		}
	},
	applySort : function(){
		Ext.data.GroupingStore.superclass.applySort.call(this);
		if(!this.groupOnSort && !this.remoteGroup){
			if(this.groupField != this.sortInfo.field || this.groupDir != this.sortInfo.direction){
				this.sortData(this.groupField, this.groupDir);
			}
		}
	},
	applyGrouping : function(alwaysFireChange){
		if(this.groupField !== false){
			this.groupBy(this.groupField, true, this.groupDir);
			return true;
		}else{
			if(alwaysFireChange === true){
				this.fireEvent('datachanged', this);
			}
			return false;
		}
	}
});

...and on the resource store you just need to add groupDir: 'DESC',

        var resourceStore = new Ext.data.GroupingStore({
            proxy: new Ext.data.HttpProxy({method: 'POST', url: '/azazazazaz'}),
            sortInfo: { field: 'Id', direction: "DESC" },
            groupField: 'Group',
            groupDir: 'DESC',
            //idProperty: 'id',
            baseParams: {start: 0, limit: 8},     
            reader: new Ext.data.JsonReader(
                {idProperty: 'Id', root: 'rows', totalProperty: 'total'}, 
                ['Id', 'Group', 'Name', 'StartAvailability', 'EndAvailability']
            )
        });  

...like allways...so simple!

But of course, please read everything on: https://www.sencha.com/forum/showthread. ... d&p=287549 before implementing this.

Tnx!!!

Post Reply