Discuss anything related to web development but no technical support questions


Post by sarah »

hi

what is the function in the handler of save button of the event editor in the examples??

thank you

Post by mats »

Hmm, which piece of code are you referring to?

Post by sarah »

How the save button works in the demoscheduler of our example 'eventeditor'??

I am trying to add a window for new events but save button is not working...


handler: function(){
g.eventStore.commitChanges();
win.hide();
}

Post by mats »

Hmm, can you describe a bit more on how you want things to work? When a user hits the save button - you want to show a window popup?

Post by sarah »

i add a new button on the tbar of the scheduler panel to add new events which opens a new window having some field.can i add this new event to the scheduler???
	var win=new Ext.Window(
		{
		width:600,
		height:200,
		layout: 'fit',
		autocreate: true,
		closeAction: 'hide',
		title:'Add Event',
		labelWidth: 65,
		bodyBorder: true,
		border: true,
		modal: true,
		resizable: false,
		fbar: [
			{
				text: 'Save',
				disabled: false,
				handler: function(){
				g.eventStore.commitChanges();
                win.hide();
				},
				scope: this
			},
			{
				id: 'delete-btn',
				text: 'Delete',
				disabled: false,
				handler: this.onDelete,
				scope: this,
				hideMode: 'offsets'
			},
			{
				text: 'Cancel',
				disabled: false,
				handler: function(){
				win.hide();
				},
				scope: this
			}],
		items : [
			{
				frame:true,
				padding : 10,
				labelAlign : 'left',
				style:'background:#fff',
				border : false,
				closable:true,
				layout : 'form',
				flex : 2,
				defaults : {
					
				},
				items : [
					this.titleField = new Ext.form.TextField({
						anchor:'100%',
						name : 'Title',
						fieldLabel : 'Name/Company'
					}),
			
					this.locationField = new Ext.form.TextField({
						anchor:'100%',
						name : 'Purpose',
						fieldLabel : 'Purpose'
					}),
					
					this.roomField = new Ext.form.ComboBox({
						anchor:'100%',
						name : 'ResourceId',
						fieldLabel : 'Room',
						store: resourceStore,
						mode: 'local',
						valueField : 'Id',
						displayField: 'Name',
						editable: false,
						triggerAction: 'all',
						tpl: new Ext.XTemplate(
						'<tpl for=".">',
								'<tpl if="this.Category != values.Category">',
								'<tpl exec="this.Category = values.Category"></tpl>',
								'<h><b>{Category}</b></h>',
								'</tpl>',
								'<div class="x-combo-list-item">{Name}</div>',
								'</tpl>'
						)
					}),					
					{
					xtype: 'compositefield',
					fieldLabel : 'Date',
					msgTarget : 'side',
					defaults: {
						flex: 1
					},
					items: [
						
						{
							xtype: 'datefield',
							width: 100,
							name : 'StartDate'
						},
						{
							xtype: 'combo',
							width: 100,
							store:['8.00 am','8.15 am','8.30 am','8.45 am','9.00 am','9.15 am','9.30 am','9.45 am','10.00 am','10.15 am','10.30 am','10.45 am','11.00 am','11.15 am','11.30 am','11.45 am','12.00 pm','12.15 pm','12.30 pm','12.45 pm','1.00 pm','1.15 pm','1.30 pm','1.45 pm','2.00 pm','2.15 pm','2.30 pm','2.45 pm','3.00 pm','3.15 pm','3.30 pm','3.45 pm','4.00 pm','4.15 pm','4.30 pm','4.45 pm','5.00 pm','5.15 pm','5.30 pm','5.45 pm','6.00 pm','6.15 pm','6.30 pm','6.45 pm','7.00 pm'],
							name : 'StartTime'
						},
						{
						   xtype: 'displayfield',
						   value: 'to:'
						},
						{
							xtype: 'datefield',
							width: 100,
							name : 'EndDate'
						},
						{
							xtype: 'combo',
							width: 100,
							store:['8.00 am','8.15 am','8.30 am','8.45 am','9.00 am','9.15 am','9.30 am','9.45 am','10.00 am','10.15 am','10.30 am','10.45 am','11.00 am','11.15 am','11.30 am','11.45 am','12.00 pm','12.15 pm','12.30 pm','12.45 pm','1.00 pm','1.15 pm','1.30 pm','1.45 pm','2.00 pm','2.15 pm','2.30 pm','2.45 pm','3.00 pm','3.15 pm','3.30 pm','3.45 pm','4.00 pm','4.15 pm','4.30 pm','4.45 pm','5.00 pm','5.15 pm','5.30 pm','5.45 pm','6.00 pm','6.15 pm','6.30 pm','6.45 pm','7.00 pm'],
							name : 'EndTime'
						}
					
					]
				}

				]
			}
		]


	});

Post by mats »

instead of:
g.eventStore.commitChanges();

You should add a new event-record right?

var newRec = new g.eventStore.recordType({
   StartDate : ...,
   EndDate : ....,
   OtherValues : ....
});

g.eventStore.add(newRec);





Post by sarah »

hi mats,
its not working..may be i used it in a wrong way..

handler: function(){
var newRec = new g.eventStore.recordType(
{
Id : 'e26',
ResourceId: "r20",
Title : "tom",
Purpose : "aa",
StartDate : "2011-05-14 8:00",
EndDate : "2011-05-14 14:00"
});

g.eventStore.add(newRec);
win.hide();
}

result in an error:

a.getTime is not a function
https://localhost/Ext%20Scheduler%20Tria ... l-debug.js

Post by mats »

Startdate and end date should be native date objects, not strings.

Post by sarah »

thank you.... mats... :)

Post Reply