how to connect main view to popup view such that when we click on the row of table in main window and press delete button in main window then a popup view in get open to confirm whether you want to delete with yes and no button when we press yes row get deleted otherwise not
Have a look at Perspective Utility Scripts by @Ryan McLaughlin on the Exchange.
It's nicely done.
For anyone new to exporting components from exchange projects into your own projects - be careful. For example, exporting the Perspective Properties from one project (such as the Utility Scripts above) into an existing project will overwrite the target's Perspective properties. In general, most of the authors seem to be using folders for styles and views, etc., so they are unlikely to overwrite anything in the target and can be easily identified there. Backup your target project first!
I wouldn’t do this directly on row selection, so I’ll suggest 2 alternatives:
- add a column to the table containing buttons. This would be done by rendering a view, itself containing the button. This view would take the row index or id, can’t remember which one. Clicking this button would open the pop up, passing it the row id.
- add a button outside of the table, that would open a popup when clicked, passing it the selected row as argument
From there, both solutions converge.
Now, the popup’s view contain 2 buttons: one will just close the popup to cancel the action, the other one will send a message, with the row id as payload.
On the table, put a message handler, that will listen to the message sent by the confirm popup, and use the row id found in the payload to delete the corresponding row.
You may need additional parameters on the popup view, a popup id for starters to make sure you’re closing the right popup when clicking the buttons, and maybe a table of to filter incoming messages if you have more than one table with the message handler on the same page.