in YII2 how to post data using modal dialog? - modal-dialog

I'm using modal dialog. I'm working with two modal. User Model and STATE Model where
User is Parent model and state/create is open in modal dialog.
when I'm creating new User, I have select state name from drop-down, if it is not listed in dd then it will create state by clicking add new state and open in modal dialog and create state.
Issue is after create new state parent page is refresh and all the data which I have added are removed.
Kindly guide me. I have created modal dialog by below link

Not sure if I understand your problem correctly because there is no example code. But if you have separate form to add new state then you can submit that form with ajax using beforeSubmitevent of ActiveForm.
An example of beforeSubmitevent implementation you can find in this issue
Also in your controller action you will have to set response type to json like following
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
More info on response types.

Related

How to pass values to a new open(created) window (dialog, panel, page etc) with MVVM in Blazor

I have "PageMain" with "PageMainViewModel" binded, there is a "Edit" button in "PageMain", What is the best practice in MVVM for Blazor to pass the values(example:ProductInfo) to the new opened edit form window ("EditFormWindow") when the "Edit" button is clicked?
I used to use the massagers to communicate between each viewmodel, but in this case, the "EditFormWindow" is new opened, Even I added a register of messager in the constructor of "EditFormWindowViewModel", when sending message (passing data) from "PageMainViewModel", the "EditFormWindowViewModel" is not initialized yet so "EditFormWindowViewModel" cannot receive the message(passed data) from "EditFormWindow".
What I am doing now is to pass the values from View (Balzor file) to Viewmodel, but I am wondering if there is a better solution that I don't have to write any codes in View(Blazor file).

How to pass an object while routing to new view in SAPUI5

In my application, I am opening a new page in a new tab when the user clicked on a button. This new page displays the data which it received from the previous page. I am able to retain the object data by setting the JSON model to the UI core or view if I use navTo() and don't load the view in a new tab. But, when I try to open the view in a new tab the model is getting destroyed.
Please, let me know if this can be achieved in UI5 and how.
Thanks in advance.
Venkatesh.

Best way to update view from command or filedialog in an eclipse rcp application

In my application I have a menu which open a SelectionDialog, this dialog is used to choose an object.
When this object is selected I have to display it in the view.
What is the best way to update my view?
Currently, I call myview.update(object) after the dialog is closed (in the handler of the menu). But I think this solution is not well design.
I have read about update my model and notify my view but my model does not change (no data are changed, I only display different Data ).
Does anyone has some ideas for a well design solution ?
Define model listener ( dataPopulated(Event e))
Make your view implement model listener and register it with the Model.
Define a Model class that can contain the objects that you want to populate in the view
When Model.setInput(Object input) is invoked fire dataPopulated() event on all registered model listeners.
Above steps works properly when you have view activated. You need to consider cases like when if view is deactivated or not visible ( make sure you refresh view is visible else you will have unnecessary overhead of refreshing view though it is notvisible)
Try adding a selection listener in the view and register this selection in the dialog.
In the listener action, add the code to show the selected object.

Saving page preference in site navigation using SiteMapPath control

I have created site navigation in my ASP.net application using SiteMapPath control and its working fine. Now my requirement is that, there is open page in my application which has Radio buttons and based on their selection datagrid is populated from database. I want to save the radio button selection in navigation url so that when I click on that page through navigation url then page will display the data from my selected options.
Any help would be highly appriciated.
Thanks,
Yogesh
I'm not sure that I understand. I propose some other solution (using Session). Add event to radioButton onSelectionChange. When selection change, remember this in Session
Session["name_param"] = some_params;
And in form with dataGrid get event PageLoad with code:
if ( Session["name_param"] != null ) {
var param = Session["name_param"];
// using param to load data to grid
} else {
// something else, maybe default chance for data to grid
}

How to create a "New xxx" popup?

I have a Grid object and added a [ (+) New Client ] button which I'd like to open a popup form to create the new client with a couple fields.
I've looked at the code examples in the website but haven't found how to do it (sorry if I've missed something).
This is the current page code:
function page_clients_listing($p){
$g = $p->add('Grid');
$g->addColumn('text','first_name');
$g->addColumn('text','last_name');
$g->addColumn('inline','telephone');
$g->addColumn('expander','comments');
$g->setSource('client');
$g->addButton('With Icon')->set('Add New Client')->setIcon('Plus');
}
Thanks in advance!
You can either create a popup or a dialog. Dialog is based on jQuery UI dialog implementation. Popups are likely to be blocked and are harder to control.
This is actually working for any object (you can apply to view, button, image, icon, etc), but I'll use button).
$b=$g->addButton('Add New Client')->setIcon('Plus');
$b->js('click')->univ()->frameURL($title,$url);
// OR
$b->js('click')->univ()->dialogURL($title,$url);
$url would most likely be returned by api->getDestinationURL(). The other page would be loaded and scripts on that page will be evaluated. Let's say you are on other page and now need to close the window.
$result = $this->addButton('Close')->js('click')->univ()->closeDialog();
closeDialog() returns a jQuery chain object pointing to a view which originally opened the frame. As a result if you do $result->hide(); then after dialog is closed, the original button ('add new client') will also be hidden.
Here is example to show some additional things you can do with frames, reloading and custom event handlers:
http://agiletoolkit.org/example/refresh1