Skip to content

Instantly share code, notes, and snippets.

@YuriyZaletskyy
Last active April 14, 2020 08:36
Show Gist options
  • Save YuriyZaletskyy/1011674c7860de06ed1fc36562800d1e to your computer and use it in GitHub Desktop.
Save YuriyZaletskyy/1011674c7860de06ed1fc36562800d1e to your computer and use it in GitHub Desktop.
Gist that demonstrates Pop up functionality with aspx markup
[PXCopyPasteHiddenView]
public SelectFrom<Contact>.
Where<Contact.contactType.IsEqual<ContactTypesAttribute.employee>.
And<Contact.isActive.IsEqual<True>>.
And<Contact.userID.IsNotNull>>.OrderBy<Asc<Contact.displayName>>.View UsersForAddition;
public PXAction<Survey> AddRecipients;
[PXButton]
[PXUIField(DisplayName = "Add Recipients", MapViewRights = PXCacheRights.Select,
MapEnableRights = PXCacheRights.Select)]
public virtual IEnumerable addRecipients(PXAdapter adapter)
{
if (UsersForAddition.AskExt((graph, viewName) =>
{
graph.Views[UsersForAddition.View.Name].Cache.Clear();
graph.Views[viewName].Cache.Clear();
graph.Views[viewName].Cache.ClearQueryCache();
graph.Views[viewName].ClearDialog();
}, true) != WebDialogResult.OK)
return adapter.Get();
return addUsers(adapter);
}
public PXAction<Survey> AddUsers;
[PXUIField(DisplayName = "Add", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(VisibleOnDataSource = false)]
public virtual IEnumerable addUsers(PXAdapter adapter)
{
var users = UsersForAddition.Select().Where(a => a.GetItem<Contact>().Selected == true).ToList();
foreach (var user in users)
{
var surveyUser = new SurveyUser();
surveyUser.Active = true;
surveyUser.SurveyID = SurveyCurrent.Current.SurveyID;
surveyUser.ContactID = user.GetItem<Contact>().ContactID;
surveyUser = SurveyUsers.Insert(surveyUser);
}
return adapter.Get();
}
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="PX.Survey.Ext.SurveyMaint" PrimaryView="SurveyCurrent">
<CallbackCommands>
<px:PXDSCallbackCommand Name="AddRecipients" Visible="False" />
</CallbackCommands>
</px:PXDataSource>
<px:PXSmartPanel ID="PanelAddRecipients" runat="server" Key="UsersForAddition" LoadOnDemand="true" Width="1100px" Height="500px"
Caption="Select Recipients" CaptionVisible="true" AutoRepaint="true" DesignView="Content" ShowAfterLoad="true">
<px:PXGrid ID="grdRecipientContacts" runat="server" DataSourceID="ds" Height="150px" Width="100%" ActionsPosition="Top" SkinID="Inquire"
SyncPosition="True" NoteIndicator="False" FilesIndicator="False" TabIndex="4900" AllowPaging="true">
<Levels>
<px:PXGridLevel DataMember="UsersForAddition">
<RowTemplate>
</RowTemplate>
<Columns>
<px:PXGridColumn CommitChanges="true" DataField="Selected" TextAlign="Center" Type="CheckBox" />
<px:PXGridColumn DataField="DisplayName" Width="280px" />
<px:PXGridColumn DataField="ContactType" />
<%--some more columns--%>
<px:PXGridColumn DataField="UsrUsingMobileApp" Width="180px" TextAlign="Center" Type="CheckBox" />
<px:PXGridColumn DataField="FirstName" Width="180px" />
<px:PXGridColumn DataField="LastName" Width="220px" />
<px:PXGridColumn DataField="BAccountID_BAccount_acctName" Width="280px" />
<px:PXGridColumn DataField="EMail" Width="280px" />
<px:PXGridColumn DataField="Phone1" Width="180px" />
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Enabled="True" MinHeight="150" />
</px:PXGrid>
<px:PXPanel ID="pnlButtons" runat="server" SkinID="Buttons">
<px:PXButton ID="btnAdd" runat="server" CommandSourceID="ds" Text="Add" CommandName="AddUsers" /> <%--as you guessed this is markup of button add--%>
<px:PXButton ID="btnAddAndClose" runat="server" Text="Add & Close" DialogResult="OK" /> <%--and this is markup of button Add and close. Pay attention to DialogResult part--%>
<px:PXButton ID="btnCancel" runat="server" DialogResult="Cancel" Text="Cancel" /> <%--and this button just will close the dialog window--%>
</px:PXPanel>
</px:PXSmartPanel>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment