Page Index Toggle Pages: [1] 2 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Page will be refreshed automatically after item creation/deleting/modification (Read 39250 times)
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Page will be refreshed automatically after item creation/deleting/modification
May 5th, 2014 at 3:04pm
Print Post  
Hi there,

Originally I would like to build my page like the sample page "Scheduling.Demo", the moments such as item creation/deleting/modification will only change the corresponding item but not refreshing the entire page.

But now my page will do that, seems it is because of I set "AutoPost = true" thus once I delete this autopostback code, the page will not be refreshed itself but also it won't call ItemModifyingscript to change item bar color.

my code:
Code
Select All
<MindFusion:Calendar ID="_calendar" runat="server" Height="490px" Width="100%" Theme="Vista"
					CurrentView="ResourceView" Culture="(Default)" AutoPostBack="true"
                        OnVisibleDateChanged="_calendar_VisibleDateChanged" GroupType="GroupByContacts"
                            ItemCreatingScript="itemCreating" ItemModifyingScript="itemModifying"
                                 CalendarLoadScript="onCalendarLoad"
                                FormShowScript="formShow" ItemDeletingScript="ConfirmDelete"
                                    OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified"> 



here the first two
Code
Select All
ItemCreatingScript="itemCreating" ItemModifyingScript="itemModifying" 


is to assign the right color to the item bar on calendar after creation or modification, then the four
Code
Select All
OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified" 


is calling code behind to change the static datatable based on the creation/deletion/modification. I have a button to upload the entire datatable to database after the creation/deletion/modification are completed.

Is there any way that could achieve page creation/deletion/modification but not refresh it until uploading to database?

Say the creation/deletion/modification will only change the back end static datatable, change the corresponding item bar on the calendar, but not refresh the entire page, then once button "Save" is clicked, the datatable will be upload to database.

Right now my page will be refreshed after every reation/deletion/modification.

-----------------------------------
Add:

if I remove autopostback = true and change
Code
Select All
ItemModifingScript="itemModifying" 

to
Code
Select All
ItemModifiedScript="itemModified" 

, once I modify the item bar on calendar it will throw error: Quote:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'get_changes'

Actually the function "itemModifying" and "itemModified" have the same code.

Thank you!
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #1 - May 6th, 2014 at 1:04pm
Print Post  
Hi,

Indeed, when AutoPostBack is set to true, the control automatically posts the page back after every item interaction - creation, modification, deletion, etc. To achieve the needed behavior, you need to disable it and use the technique described in the second point of this post: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40. As detailed there you can post back the page yourself only when needed - i.e. before synchronizing your DataTable with the database or in response to some user interaction, explicitly, etc.

As for your other question - the ItemModified and ItemModifying client events use different event args implementations - ItemChangedEventArgs and ItemModifyingEventArgs classes respectively. The ItemChangedEventArgs doesn't support the changes property, hence the error you're receiving. More on client events is detailed in this topic in the help file.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #2 - May 6th, 2014 at 2:23pm
Print Post  
But if I disable the autopostback, once I change the location value it won't call "ItemModifying" scripts to assign the css color. because the color of the event bar on calendar is based on the locations.
Code
Select All
function itemModifying(sender, args) {
		        if (args.get_changes().location) {
		            //var loc = sender.getResourceById(args.get_changes().location);
		            var loc = args.get_changes().location;
		            switch (loc) {
		                case "6":
		                    sender.editItem(args.get_item(), { cssClass: "Event6CssClass" });
		                    break;

		                case "7":
		                    sender.editItem(args.get_item(), { cssClass: "Event7CssClass" });
		                    break;

		                case "685":
		                    sender.editItem(args.get_item(), { cssClass: "Event685CssClass" });
		                    break;

		                case "686":
		                    sender.editItem(args.get_item(), { cssClass: "Event686CssClass" });
		                    break;
		            }
		        }
		    }

		    function itemModified(sender, args) {
		        if (args.get_changes().location) {
		            //var loc = sender.getResourceById(args.get_changes().location);
		            var loc = args.get_changes().location;
		            switch (loc) {
		                case "6":
		                    sender.editItem(args.get_item(), { cssClass: "Event6CssClass" });
		                    break;

		                case "7":
		                    sender.editItem(args.get_item(), { cssClass: "Event7CssClass" });
		                    break;

		                case "685":
		                    sender.editItem(args.get_item(), { cssClass: "Event685CssClass" });
		                    break;

		                case "686":
		                    sender.editItem(args.get_item(), { cssClass: "Event686CssClass" });
		                    break;
		            }
		        }
		    } 




Lyubo wrote on May 6th, 2014 at 1:04pm:
Hi,

Indeed, when AutoPostBack is set to true, the control automatically posts the page back after every item interaction - creation, modification, deletion, etc. To achieve the needed behavior, you need to disable it and use the technique described in the second point of this post: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40. As detailed there you can post back the page yourself only when needed - i.e. before synchronizing your DataTable with the database or in response to some user interaction, explicitly, etc.

As for your other question - the ItemModified and ItemModifying client events use different event args implementations - ItemChangedEventArgs and ItemModifyingEventArgs classes respectively. The ItemChangedEventArgs doesn't support the changes property, hence the error you're receiving. More on client events is detailed in this topic in the help file.

Regards,
Lyubo
« Last Edit: May 6th, 2014 at 9:55pm by Xylon »  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #3 - May 6th, 2014 at 10:01pm
Print Post  
And if I disable the autopostback,
Code
Select All
AutoPostback ="false" 



Why the properties
Code
Select All
OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified" 



are all disabled? I mean page won't invoke them if AutoPostback is disabled.

Right now if I enable the AutoPostback, every interaction will refresh the page and it is Really slow!!! But if I disable the AutoPostback, page won't invoke the calendar properties above to create/edit/delete the records in backnd datatable.

I update my database with the datatable.



Lyubo wrote on May 6th, 2014 at 1:04pm:
Hi,

Indeed, when AutoPostBack is set to true, the control automatically posts the page back after every item interaction - creation, modification, deletion, etc. To achieve the needed behavior, you need to disable it and use the technique described in the second point of this post: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40. As detailed there you can post back the page yourself only when needed - i.e. before synchronizing your DataTable with the database or in response to some user interaction, explicitly, etc.

As for your other question - the ItemModified and ItemModifying client events use different event args implementations - ItemChangedEventArgs and ItemModifyingEventArgs classes respectively. The ItemChangedEventArgs doesn't support the changes property, hence the error you're receiving. More on client events is detailed in this topic in the help file.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #4 - May 7th, 2014 at 5:51am
Print Post  
Xylon wrote on May 6th, 2014 at 2:23pm:
But if I disable the autopostback, once I change the location value it won't call "ItemModifying" scripts to assign the css color.

The validation client-side events - ItemModifying, ItemCreating, etc - are not linked in any way with the AutoPostBack property. The events are raised in my test in both cases - with AutoPostBack set to true/false. Check for some errors in your code that may be the cause of this problem.

Xylon wrote on May 6th, 2014 at 10:01pm:
And if I disable the autopostback,
Code
Select All
AutoPostback ="false" 



Why the properties
Code
Select All
OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified" 



are all disabled? I mean page won't invoke them if AutoPostback is disabled.

As I said in my previous post, if you disable AutoPostBack, the control will no longer automatically post the page back - you need to do that manually. Call the calendar.postback method to do that. I posted a snippet here: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40.

Xylon wrote on May 6th, 2014 at 10:01pm:
Right now if I enable the AutoPostback, every interaction will refresh the page and it is Really slow!!!

That depends on the size of the ViewState and your network speed. Also, if you're syncronizing your database on every refresh, that also can contribute to e a very slow page update.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #5 - May 7th, 2014 at 2:28pm
Print Post  
Weird, I put a breakpoint on the function "itemModifying", then test it. In either case whether the autopostback is on/off, this function will be invoked, but finally the color only be changed if the autopostback is on.

I'll try to find the issue...

Lyubo wrote on May 7th, 2014 at 5:51am:
Xylon wrote on May 6th, 2014 at 2:23pm:
But if I disable the autopostback, once I change the location value it won't call "ItemModifying" scripts to assign the css color.

The validation client-side events - ItemModifying, ItemCreating, etc - are not linked in any way with the AutoPostBack property. The events are raised in my test in both cases - with AutoPostBack set to true/false. Check for some errors in your code that may be the cause of this problem.

Xylon wrote on May 6th, 2014 at 10:01pm:
And if I disable the autopostback,
Code
Select All
AutoPostback ="false" 



Why the properties
Code
Select All
OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified" 



are all disabled? I mean page won't invoke them if AutoPostback is disabled.

As I said in my previous post, if you disable AutoPostBack, the control will no longer automatically post the page back - you need to do that manually. Call the calendar.postback method to do that. I posted a snippet here: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40.

Xylon wrote on May 6th, 2014 at 10:01pm:
Right now if I enable the AutoPostback, every interaction will refresh the page and it is Really slow!!!

That depends on the size of the ViewState and your network speed. Also, if you're syncronizing your database on every refresh, that also can contribute to e a very slow page update.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #6 - May 8th, 2014 at 6:15pm
Print Post  
Is there any built-in filter that could group the location collection?

Say on the new appointment window, if the new appointment is being created for contact A, the location dropdown list is L1, L2, L3 etc..
If the new appointment is being created for contact B, the location dropdown list is L4, L5, L6 etc....

My page right now only could load the entire locations to calendar location collection so that no matter on which contact I am creating new appointment, the location drop down list will show all the locations.

Lyubo wrote on May 7th, 2014 at 5:51am:
Xylon wrote on May 6th, 2014 at 2:23pm:
But if I disable the autopostback, once I change the location value it won't call "ItemModifying" scripts to assign the css color.

The validation client-side events - ItemModifying, ItemCreating, etc - are not linked in any way with the AutoPostBack property. The events are raised in my test in both cases - with AutoPostBack set to true/false. Check for some errors in your code that may be the cause of this problem.

Xylon wrote on May 6th, 2014 at 10:01pm:
And if I disable the autopostback,
Code
Select All
AutoPostback ="false" 



Why the properties
Code
Select All
OnItemCreated="_calendar_ItemCreated" OnItemDeleted="_calendar_ItemDeleted"
                                            OnItemInplaceEdited="_calendar_ItemInplaceEdited"
                                                OnItemModified="_calendar_ItemModified" 



are all disabled? I mean page won't invoke them if AutoPostback is disabled.

As I said in my previous post, if you disable AutoPostBack, the control will no longer automatically post the page back - you need to do that manually. Call the calendar.postback method to do that. I posted a snippet here: http://mindfusion.eu/Forum/YaBB.pl?num=1393954368/40#40.

Xylon wrote on May 6th, 2014 at 10:01pm:
Right now if I enable the AutoPostback, every interaction will refresh the page and it is Really slow!!!

That depends on the size of the ViewState and your network speed. Also, if you're syncronizing your database on every refresh, that also can contribute to e a very slow page update.

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #7 - May 9th, 2014 at 7:06am
Print Post  
Hi,

There's no built-in filter for locations based on contacts, but this behavior can be easily achieved through some DOM manipulation from the FormShow client side event. Before the form is displayed, you can check the item's contact, and then remove the corresponding locations from the locations dropdown control. Here's one way to do this:
Code (Javascript)
Select All
function onFormShow(sender, args) {
    var frm = args.get_form();
    if (frm.getId() == "EditForm") {
        var itemContactId = frm.getItem().contacts[0];
        // The item at 0 index in the location drop-down is the "empty item",
        // so the first location is at index 1, the second at 2, etc.
        if (itemContactId == sender.getContacts()[0].getId()) {
            frm.getControls()["location"].element.remove(1);
        }
        else if (itemContactId == sender.getContacts()[1].getId()) {
            frm.getControls()["location"].element.remove(2);
        }
    }
} 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #8 - May 9th, 2014 at 7:56pm
Print Post  
That's awesome!

Thank you very much!

I set one of my appointment as "app.locked = true", but why this one still can be deleted? Is it only disabling the modification not deletion? 

Lyubo wrote on May 9th, 2014 at 7:06am:
Hi,

There's no built-in filter for locations based on contacts, but this behavior can be easily achieved through some DOM manipulation from the FormShow client side event. Before the form is displayed, you can check the item's contact, and then remove the corresponding locations from the locations dropdown control. Here's one way to do this:
Code (Javascript)
Select All
function onFormShow(sender, args) {
    var frm = args.get_form();
    if (frm.getId() == "EditForm") {
        var itemContactId = frm.getItem().contacts[0];
        // The item at 0 index in the location drop-down is the "empty item",
        // so the first location is at index 1, the second at 2, etc.
        if (itemContactId == sender.getContacts()[0].getId()) {
            frm.getControls()["location"].element.remove(1);
        }
        else if (itemContactId == sender.getContacts()[1].getId()) {
            frm.getControls()["location"].element.remove(2);
        }
    }
} 



Regards,
Lyubo

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #9 - May 12th, 2014 at 5:59am
Print Post  
Hi,

Yes, the Locked property blocks only item interactive modifications. To prevent users from deleting items from the schedule, handle the ItemDeleting client event, and set the cancel property of the args object to true:

Code (Javascript)
Select All
function onItemDeleting(sender, args) {
    if (args.get_item().getLocked())
        args.set_cancel(true);
} 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #10 - May 13th, 2014 at 2:01pm
Print Post  
Great, thank you very much!

I was trying to put a separator between to contacts, which is like a black bar between two contacts. So I simply added a new null contact with an appointment from calendar start date to end date. So that the user won't get confused if the two appointments are so close.

That's why I tried to lock the appointment.

My code is simple:
Code
Select All
        private void AddSeparator()
        {
            Contact c = new Contact();

            string tname = "Separator";
            c.FirstName = "   ";
            c.Tag = tname;

            _calendar.Schedule.Contacts.Add(c);
            _calendar.Contacts.Add(c);


            var app = new Appointment();

            int startYear = calStartYr;
            int endYear = calEndYr;
            DateTime myStartDate = new DateTime(startYear, 1, 1);
            DateTime myEndDate = new DateTime(endYear, 12, 31);

            app.HeaderText = "   ";
            app.StartTime = myStartDate;
            app.EndTime = myEndDate;
            app.Tag = tname;
            app.Locked = true;
            app.AllowChangeEnd = false;
            app.AllowChangeStart = false;
            app.AllowMove = false;
            app.CssClass = "SeparatorCssClass";

            app.Contacts.Add(c);
            _calendar.Schedule.Items.Add(app);
        } 



Before I add the separator, everything works good.

Once I add the separator, say I try to delete any existing appointment which is not the separator, page throws an error as attached. I try to solve it but no matter how I modify my "AddSeparator" function or test the function, the error is always being appeared.

Any hint?

Thank you!

Lyubo wrote on May 12th, 2014 at 5:59am:
Hi,

Yes, the Locked property blocks only item interactive modifications. To prevent users from deleting items from the schedule, handle the ItemDeleting client event, and set the cancel property of the args object to true:

Code (Javascript)
Select All
function onItemDeleting(sender, args) {
    if (args.get_item().getLocked())
        args.set_cancel(true);
} 



Regards,
Lyubo
  

q17.JPG (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #11 - May 14th, 2014 at 9:36am
Print Post  
Hi,

I'm not able to reproduce the issue and I cannot see anything wrong with the posted code snippet. Where are you calling the AddSeparator method? Also, could you post here the SeparatorCssClass style, so that we could investigate if it's a CSS issue?

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #12 - May 14th, 2014 at 1:33pm
Print Post  
Code (CSS)
Select All
        .SeparatorCssClass .frame,
        .SeparatorCssClass .wrapper {
            background-image: none !important;
            background-color: Black !important;
        } 



I have a function to loop the datatable from database which contains the schedule details. In each loop of course the function will load the contact and its corresponding appointment. Then at the end of each loop function AddSeparator will be invoked to add the separator.

Like this:
Code
Select All
for(int i = 0; i < dt.rows.count; i++)
{
    //assign schedule from datatable to calendar;
    addSeparator();
} 




That's really a weird issue coz I absolutely follow the sample code to add the separator. As you can see in fact the separator is a contact with a cross calendar appointment. Should work but not
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #13 - May 14th, 2014 at 1:54pm
Print Post  
Still can't replicate. Can you send us a small sample project that reproduces the issue at support@mindfusion.eu or attach it here?

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: Page will be refreshed automatically after item creation/deleting/modification
Reply #14 - May 15th, 2014 at 1:29pm
Print Post  
I am not allowed to share the entire project, but let me get some snippet

Lyubo wrote on May 14th, 2014 at 1:54pm:
Still can't replicate. Can you send us a small sample project that reproduces the issue at support@mindfusion.eu or attach it here?

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send TopicPrint