[CLOSED] Calendar - Change EventEditForm

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Calendar - Change EventEditForm

    I can't figure out how to change the event edit form. Even creating a simple listener on the EventEditForm like below messes up the form. Every time you go in and out of the EditForm the fields are duplicated.

    I think this is a bug.

    <ext:EventEditForm runat="server" Hidden="true" GroupStoreID="storeEventGroups">
        <Listeners>
            <Render Fn="MyCompany.setupEditForm" Scope="MyCompany" />
        </Listeners>
    </ext:EventEditForm>
    Last edited by Daniil; Feb 07, 2011 at 2:45 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please do not create <ext:EventEditForm> control manually, it is created internally.

    I would suggest you to use BeforeRender listener of CalendarPanel.

    Example
    <ext:CalendarPanel ...>
        ...
        <Listeners>        
            <BeforeRender Handler=" var form = this.get(this.id + '-edit');
                                    form.get('left-col').add({id: 'TextField1', fieldLabel: 'LEFT', xtype:'textfield'});
                                    form.get('right-col').add({id: 'TextField2', fieldLabel: 'RIGHT', xtype:'textfield'});" />
        </Listeners>
    </ext:CalendarPanel>
    Last edited by Daniil; Jan 30, 2011 at 9:52 PM.
  3. #3
    This is good and it works, but I really want to add some details here without having to do everything in javascript.

    Can I just have access to the template and create my own look and feel? Is it all in the source code? If so, what file?

    Also, when adding new fields to the form, how do i set values for existing records or tell if i'm doing an Add or an Edit? I'm not sure what values are passed into the handler by default.
  4. #4
    To achieve your requirements it needs to deal with JavaScript, there is no way to avoid it.

    JavaSript code of EventEditForm widget is here
    <SVN folder>\Ext.Net\Build\Ext.Net\ux\extensions\calend ar\src\EventEditForm.js

    <ext:EventEditForm> control is a wrapper of this widget.

    You could create your own CustomEventEditForm widget using default EventEditForm one as base.

    To attach your widget to Calendar please use its editViewCfg config option. Find this key word 'editViewCfg ' in to get more information:
    <SVN folder>\Ext.Net\Build\Ext.Net\ux\extensions\calend ar\src\CalendarPanel.js

    Note

    It would be a rather difficult task for someone who is not so experienced in ExtJS / JavaScript.
    Last edited by Daniil; Feb 01, 2011 at 10:06 AM. Reason: Added note
  5. #5
    When adding new fields to the form, how do i set values for existing records and tell if i'm doing an Add or an Edit? I'm not sure what values are passed into the handler by default.


    <ext:CalendarPanel ...>
        ...
        <Listeners>        
            <BeforeRender Handler=" var form = this.get(this.id + '-edit');
                                    form.get('left-col').add({id: 'TextField1', fieldLabel: 'LEFT', xtype:'textfield'});
                                    form.get('right-col').add({id: 'TextField2', fieldLabel: 'RIGHT', xtype:'textfield'});" />
        </Listeners>
    </ext:CalendarPanel>
  6. #6
    Hi,

    Please try to set respective .dataIndex for TextFields.

    Example
    form.get('left-col').add({id: 'TextField1', fieldLabel: 'LEFT', xtype:'textfield', dataIndex: 'first additional dataIndex'});
    form.get('right-col').add({id: 'TextField2', fieldLabel: 'RIGHT', xtype:'textfield', dataIndex: 'second additional dataIndex'});
  7. #7
    sorry, i don't understand what that is or what you mean.

    I was hoping to just set the handler to a function like the Edit, Remove, or Show handlers.

    edit: function (win, rec) {
    
    }
    And then be able to easily access the record via a parameter. rec.value1
    Last edited by Daniil; Feb 01, 2011 at 4:42 PM. Reason: Please use [CODE] tags
  8. #8
    Quote Originally Posted by craig2005 View Post
    sorry, i don't understand what that is or what you mean.
    I meant something like the example below. Please investigate and ask further questions basing on this example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        class MyEvent : Event
        {
            public string Test1 { get; set; }
            public string Test2 { get; set; }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            this.CalendarPanel1.EventStore.AddStandardFields();
            this.CalendarPanel1.EventStore.Reader[0].Fields.Add(new RecordField("Test1"));
            this.CalendarPanel1.EventStore.Reader[0].Fields.Add(new RecordField("Test2"));
    
    
            if (!X.IsAjaxRequest)
            {
                Store store = this.CalendarPanel1.EventStore;
                store.DataSource = new List<object> 
                { 
                    new MyEvent()
                    { 
                        Title = "My event",
                        CalendarId = 1,
                        StartDate =  DateTime.Now,
                        EndDate =  DateTime.Now.AddDays(1),
                        EventId = 1,
                        Test1 = "I'm first",
                        Test2 = "I'm second"
                    }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var CompanyX = {
                getCalendar: function() {
                    return CompanyX.CalendarPanel1;
                },
    
                getStore: function() {
                    return CompanyX.EventStore1;
                },
    
                getWindow: function() {
                    return CompanyX.EventEditWindow1;
                },
    
                updateTitle: function(startDt, endDt) {
                    var msg = '';
    
                    if (startDt.clearTime().getTime() == endDt.clearTime().getTime()) {
                        msg = startDt.format('F j, Y');
                    } else if (startDt.getFullYear() == endDt.getFullYear()) {
                        if (startDt.getMonth() == endDt.getMonth()) {
                            msg = startDt.format('F j') + ' - ' + endDt.format('j, Y');
                        } else {
                            msg = startDt.format('F j') + ' - ' + endDt.format('F j, Y');
                        }
                    } else {
                        msg = startDt.format('F j, Y') + ' - ' + endDt.format('F j, Y');
                    }
    
                    this.Panel1.setTitle(msg);
                },
    
                setStartDate: function(picker, date) {
                    this.getCalendar().setStartDate(date);
                },
    
                rangeSelect: function(cal, dates, callback) {
                    this.record.show(cal, dates);
                    this.getWindow().on('hide', callback, cal, { single: true });
                },
    
                dayClick: function(cal, dt, allDay, el) {
                    this.record.show.call(this, cal, {
                        StartDate: dt,
                        IsAllDay: allDay
                    }, el);
                },
    
                record: {
                    add: function(win, rec) {
                        win.hide();
                        rec.data.IsNew = false;
                        CompanyX.getStore().add(rec);
                        CompanyX.ShowMsg('Event ' + rec.data.Title + ' was added');
                    },
    
                    update: function(win, rec) {
                        win.hide();
                        rec.commit();
                        CompanyX.ShowMsg('Event ' + rec.data.Title + ' was updated');
                    },
    
                    remove: function(win, rec) {
                        this.getStore().remove(rec);
                        win.hide();
                        CompanyX.ShowMsg('Event ' + rec.data.Title + ' was deleted');
                    },
    
                    edit: function(win, rec) {
                        win.hide();
                        CompanyX.getCalendar().showEditForm(rec);
                    },
    
                    resize: function(cal, rec) {
                        rec.commit();
                        CompanyX.ShowMsg('Event ' + rec.data.Title + ' was updated');
                    },
    
                    move: function(cal, rec) {
                        rec.commit();
                        CompanyX.ShowMsg('Event ' + rec.data.Title + ' was moved to ' + rec.data.StartDate.format('F jS' + (rec.data.IsAllDay ? '' : ' \\a\\t g:i a')));
                    },
    
                    show: function(cal, rec, el) {
                        CompanyX.getWindow().show(rec, el);
                    },
    
                    saveAll: function() {
                        CompanyX.getStore().submitData();
                    }
                }
            };        
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" Namespace="CompanyX" />
        <ext:Viewport runat="server" Layout="fit">
            <Items>
                <ext:CalendarPanel ID="CalendarPanel1" runat="server" Height="500">
                    <EventStore runat="server" />
                    <GroupStore ID="GroupStore1" runat="server">
                        <Groups>
                            <ext:Group CalendarId="1" Title="Home" />
                            <ext:Group CalendarId="2" Title="Work" />
                            <ext:Group CalendarId="3" Title="School" />
                            <ext:Group CalendarId="4" Title="Other" />
                        </Groups>
                    </GroupStore>
                    <Listeners>
                        <EventClick Fn="CompanyX.record.show" Scope="CompanyX" />
                        <DayClick Fn="CompanyX.dayClick" Scope="CompanyX" />
                        <RangeSelect Fn="CompanyX.rangeSelect" Scope="CompanyX" />
                        <EventMove Fn="CompanyX.record.move" Scope="CompanyX" />
                        <EventResize Fn="CompanyX.record.resize" Scope="CompanyX" />
                        <BeforeRender Handler=" var form = this.get(this.id + '-edit');
                                                form.get('left-col').add({id: 'TextField1', fieldLabel: 'LEFT', xtype:'textfield', dataIndex: 'Test1'});
                                                form.get('right-col').add({id: 'TextField2', fieldLabel: 'RIGHT', xtype:'textfield', dataIndex: 'Test2'});" />
                    </Listeners>
                </ext:CalendarPanel>
            </Items>
        </ext:Viewport>
        <ext:EventEditWindow 
            ID="EventEditWindow1" 
            runat="server" 
            Hidden="true" 
            GroupStoreID="GroupStore1">
            <Listeners>
                <EventAdd Fn="CompanyX.record.add" Scope="CompanyX" />
                <EventUpdate Fn="CompanyX.record.update" Scope="CompanyX" />
                <EditDetails Fn="CompanyX.record.edit" Scope="CompanyX" />
                <EventDelete Fn="CompanyX.record.remove" Scope="CompanyX" />
            </Listeners>
        </ext:EventEditWindow>
        </form>
    </body>
    </html>
  9. #9
    oh, i got ya. I'm pretty much already handling all that on the server side. You actually don't need to pass the specific Event object. You can pass any object with the same fields plus whatever else you want. Then just add all the fields to the JsonReader.

    I just wasn't sure what you meant by "dataIndex: 'first additional dataIndex'". Sorry you had to draw all that out.

    Ok, so the syntax is "dataIndex: 'fieldName'"... got it!

    My main question was how to break the handler off to a separate method. If i did that, what params would be passed?

    <script>
     var MyHander = function(win, rec) {  
        // would i get the dataIndex passed in as the record
    }
    </script>
    
    <Listeners>
          <BeforeRender Fn="MyHander" />
    </Listeners>

    would i need to do this instead?

    <Listeners>
          <BeforeRender Fn="MyHander(dataIndex)" />
    </Listeners>
  10. #10
    Quote Originally Posted by craig2005 View Post
    oh, i got ya. I'm pretty much already handling all that on the server side. You actually don't need to pass the specific Event object. You can pass any object with the same fields plus whatever else you want. Then just add all the fields to the JsonReader.
    Yes, it also works but, for me, using standard Event object makes a solution more clear and readable.
Page 1 of 2 12 LastLast

Similar Threads

  1. EventEditForm customization
    By Dimitris in forum 1.x Help
    Replies: 1
    Last Post: May 10, 2012, 7:18 AM
  2. how to change the hour in the demo My Calendar
    By diego0404 in forum 1.x Help
    Replies: 2
    Last Post: Feb 01, 2012, 12:03 AM
  3. [CLOSED] Is it possible to change default calendar colors?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 12, 2011, 5:56 PM
  4. Calendar - EventEditForm - Direct Events
    By vwagoner in forum 1.x Help
    Replies: 4
    Last Post: Jun 17, 2011, 5:27 PM
  5. [CLOSED] [1.0] Calendar change text
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 01, 2011, 10:35 AM

Tags for this Thread

Posting Permissions