PDA

View Full Version : [CLOSED] Window popup



cwolcott
May 01, 2012, 7:37 PM
I have created an ext:window in my page that I want to use as a popup for various aspx pages.



<ext:Window ID="UserPopup" runat="server" Resizable="false" Closable="true" Hidden="true" Layout="FitLayout">
<Loader runat="server" Mode="Frame" DisableCaching="true" Url="./UserInactivate.aspx?Ids=0">
<LoadMask ShowMask="true" />
</Loader>
</ext:Window>


1) Do I need to give it a default URL?

My inactive button is defined as:



<ext:Button ID="UserInactivate" runat="server" Text="Inactivate" Icon="Delete" Disabled="true">
<Listeners>
<Click Fn="showInactivateUsersPopup" />
</Listeners>
</ext:Button>


And thus the code to popup my window is below. I am passing it the userids that are currently selected in the grid. My window is coming up, but is this the best way to perform the action?



// Show the user inactivation confirmation popup passing the currently selected userIds values as URL parameters.
function showInactivateUsersPopup() {

//#{UserPopup}.loader.url = './UserInactivate.aspx';
//#{UserPopup}.loader.params = {Ids: getSelectedRecordIds(#{ActiveUsersGridPanel}.getSe lectionModel()).join(',') };
#{UserPopup}.show(this);
#{UserPopup}.title = 'Inactivate User(s)';

// The Inactivate User window is an autoload iFrame, meaning it is a full page (not just a control).
// In order to get all of the selected userIds to it, the most straightforward solution is to
// rewrite the url with a "Ids" param whose value is a comma-seperated list of userIds.
#{UserPopup}.load({
url: './UserInactivate.aspx',
params: {Ids: getSelectedRecordIds(#{ActiveUsersGridPanel}.getSe lectionModel()).join(',') },
scripts: true,
discardUrl: true,
nocache: true
});
}

// Returns the user ID for each record currently selected in the grid.
function getSelectedRecordIds(selectionModel) {
return Ext.Array.pluck(Ext.Array.pluck (selectionModel.getSelection(), 'data'), 'UserId');
}

Daniil
May 02, 2012, 10:53 AM
Hi,


1) Do I need to give it a default URL?

No, you don't if you would set up

AutoLoad="false"

Example

<ext:Window runat="server">
<Loader runat="server" Mode="Frame" AutoLoad="false" />
</ext:Window>



And thus the code to popup my window is below. I am passing it the userids that are currently selected in the grid. My window is coming up, but is this the best way to perform the action?


Yes, I think the ways how you load the page, passing the parameters and retrieves ids of selected rows are good.

Some notes.


scripts: true

It makes sense with

Mode="Html"
only. And it's true by default. So, you can remove it if you use

Mode="Frame"

See also
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ComponentLoader-cfg-scripts


nocache: true

Please use "disableCaching" instead. It's true by default.


discardUrl: true

There is no such option anymore and no "defaultUrl" as well. Actually, I don't think you need this option at all since you don't use auto refreshing.

cwolcott
May 02, 2012, 5:33 PM
Thank you for the input. Please close the thread.