zkzk-grid

Refresh data in MVVM page after modal close (written in MVC)


I have a MVVM dialog which lists the users from the DB. There is an add button on click, it opens a modal (which is in MVC). On addition of a user, the modal closes. But the user added is not populated in the parent dialog which called the add user modal. Is there any way to populate the MVVM on data change without needing to call another method or refresh the page?


Solution

  • You could use a Global-Command.

    just before you close the modal window :

    BindUtils.postGlobalCommand(null,null,"refreshUsers",null);
    

    and in your ViewModel of the user list :

    @GlobalCommand
    @NotifyChange("users")
    public void refreshUsers(){}
    

    Note : I'm assuming you have a method getUsers. otherwise rename users to the correct getter of your users.