Perform page reload after record is saved - New UI

Posted by IramK on 16-Nov-2015 06:05

Hello,

I have created a kendo window on click of a button that opens the edit page of a particular record and when the user clicks on save in the kendo window edit page, I would like to reload the current page where the button is placed. Is there a way I could detect the event after the edit page record is saved and then perform a page reload of the parent page? Kindly let me know.

Cheers.

Iram

Posted by Thierry Ciot on 25-Nov-2015 12:47

Iram,

Small correction: do not use hardcoded value 2.  Please use rb.newui.PAGE_TYPES.EDIT

It will provide better portability across versions.

Thanks, Thierry.

The full list of page types is:

rb.newui.PAGE_TYPES = {

       GENERIC : 0,

       VIEW : 1,

       EDIT : 2,

       NEW  : 3,

       SEARCH : 4,

       SEARCH_RESULTS : 5,

       STATUS : 6,

       SELECTOR : 7,

       EMAIL_SELECTOR : 8,// Used as substitution to TYPE_SELECTOR

       TREE_SELECTOR : 9,

       IMPORT : 10,

       TEMPLATES : 12,

       REP_LIST : 13,

       REPORT   : 14,

       LOGIN    : 16,

       MASS_UPDATE : 17,

       NEW_QUICK : 18,

       CUSTOM_PAGE : 19,

       WEB_LINK : 20,

       QUESTIONS : 21,

       LIST      : 22,// List of records

       SURVEY    : 23,// Take survey

       EMBED_QC  : 24,

       R_BIN_VIEW  : 25

   };

All Replies

Posted by Shiva Duriseati on 23-Nov-2015 03:18

Hi Iram,

Can you please try  using location.reload(true) it will load the current page.

Regards,

Shiva Duriseati

Posted by ddubois on 23-Nov-2015 08:43

I find that using using location.reload(true) in Firefox causes a pop up message to appear before the page refreshes.  Using

window.location=window.location; eliminates this problem.

David

Posted by IramK on 23-Nov-2015 08:47

Hello Shiva,

location.reload(true) will reload the current page. I am however interested in reloading the parent page which I can achieve by performing a window.parent.location.reload(true); but I would only like to reload once I am sure that the value in the edit page is saved i.e. perform a parent page reload on the post-save event. Any suggestions?

Posted by Thierry Ciot on 23-Nov-2015 17:28

In next release we will provide more Ajax operations to improve the overall experience and performance of the product.

As a result, there will be a way to do the save operation with Ajax and you will get a notification when the Ajax operation is complete.  Hopefully, this will help.

Thierry.

Posted by Mohammed Siraj on 23-Nov-2015 23:48

Iram, we do not have a custom client-side event on form submit success but instead user is re-directed away from edit-pages. Else, edit page is re-rendered with validation errors.

You can consider looking at the pop-up windows current page type. Client-side API: rb.newui.page.PageContext.getPageType()

Value 2 is for Edit Page.

Posted by Mohammed Siraj on 23-Nov-2015 23:56

Also, in case of form submit failure, the following API (redirect flag on validation failure) will return TRUE:

rb.newui.page.PageContext.isRedirectedOnServerValidation().

So, this way you can test for the negative case & decide when to reload the parent page.

Posted by IramK on 25-Nov-2015 05:08

Thanks Thierry, that's great to know.

Thanks Siraj for your answer. I shall give that a try and let you know how it goes.

Cheers.

Iram

Posted by Thierry Ciot on 25-Nov-2015 12:47

Iram,

Small correction: do not use hardcoded value 2.  Please use rb.newui.PAGE_TYPES.EDIT

It will provide better portability across versions.

Thanks, Thierry.

The full list of page types is:

rb.newui.PAGE_TYPES = {

       GENERIC : 0,

       VIEW : 1,

       EDIT : 2,

       NEW  : 3,

       SEARCH : 4,

       SEARCH_RESULTS : 5,

       STATUS : 6,

       SELECTOR : 7,

       EMAIL_SELECTOR : 8,// Used as substitution to TYPE_SELECTOR

       TREE_SELECTOR : 9,

       IMPORT : 10,

       TEMPLATES : 12,

       REP_LIST : 13,

       REPORT   : 14,

       LOGIN    : 16,

       MASS_UPDATE : 17,

       NEW_QUICK : 18,

       CUSTOM_PAGE : 19,

       WEB_LINK : 20,

       QUESTIONS : 21,

       LIST      : 22,// List of records

       SURVEY    : 23,// Take survey

       EMBED_QC  : 24,

       R_BIN_VIEW  : 25

   };

Posted by Thierry Ciot on 25-Nov-2015 13:05

Note: the page type definitions above are only available as of V4.0.4.

Thus as Siraj pointed out till then use the value 2 (or better define the constant yourself)

Posted by IramK on 25-Nov-2015 13:48

I will wait for the release Thierry and then use the page type definitions as specified by you.

Cheers.

Posted by IramK on 26-Nov-2015 05:43

Hello Siraj,

I have the above mentioned code on form submit as given below that checks if the server validation is complete and the return page type is the view page but on form submit, the server validation returns false (which is correct) and the return page type returns 2 (Edit page). Any suggestions on how I can make sure the submission is complete?

if(rb.newui.page.PageContext.isRedirectedOnServerValidation() == false && rb.newui.page.PageContext.getPageType() == 1)
    {
      window.top.location.reload();
    }

Posted by Mohammed Siraj on 27-Nov-2015 08:02

Iram, on form submit when the user is re-directed, the following page  if it is an EDIT page signifies form submission failed. Else, it was a success.

That is you should not run this script on form submit but have it in  the destination page where the user will  get re-directed.

Understand that it is not that straightforward approach, but there is no custom event which signifies form submssion is success as there could be server-side validations that will cause record save to fail.

In case you do not have any  server-side field custom validation or validation triggers  configured, then you can simply check if client-side validation is a success.

For that, on form sbumit handler:

var formDetails = rb.newui.page.PageContext.getFormDetails(rb.newui.util.EDIT_FORM_NAME);

var validator = formDetails.getKendoValidator();

 if (validator && validator.validate()) { //validation true...

     window.top.location.reload();

 }

This thread is closed