Access Detail Table datakeynames on rowdrop event telerik - c#-4.0

I am using telerik nested rad grid. Please take a look at code.
<telerik:RadGrid ID="radGridRoutes" runat="server" AutoGenerateColumns="false" ShowStatusBar="True"
AllowSorting="True" AllowPaging="True" ClientSettings-Scrolling-EnableVirtualScrollPaging="false"
ClientSettings-Scrolling-AllowScroll="false"
OnNeedDataSource="Routes_NeedDataSource" OnDetailTableDataBind="radGridRoutes_DetailTableDataBind" AllowFilteringByColumn="True"
EnableLinqExpressions="false" OnInsertCommand="Routes_InsertCommand"
OnUpdateCommand="radGridRoutes_UpdateCommand"
OnItemCommand="radGridRoutes_ItemCommand"
OnPreRender="radGridRoutes_PreRender" ClientSettings-AllowRowsDragDrop="true"
OnRowDrop="radGridRoutes_RowDrop">
<ClientSettings AllowDragToGroup="True">
<Selecting AllowRowSelect="True" />
</ClientSettings>
<GroupingSettings CaseSensitive="false" />
<SelectedItemStyle CssClass="SelectedItem" />
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<ValidationSettings CommandsToValidate="PerformInsert,Update" EnableModelValidation="true"
EnableValidation="true" />
<FilterItemStyle BackColor="#F8F8F8" HorizontalAlign="Left" />
<FilterMenu EnableImageSprites="false">
</FilterMenu>
<MasterTableView DataKeyNames="ID" AllowMultiColumnSorting="false"
Width="100%" CommandItemDisplay="Top" Name="Routes">
<AlternatingItemStyle BackColor="WhiteSmoke" />
<DetailTables>
<telerik:GridTableView OnRowDrop="radGridRoutes_RowDrop" ClientSettings-AllowRowsDragDrop="true"
DataKeyNames="ID,DisplayOrder,RouteID" Width="100%" runat="server"
CommandItemDisplay="Top" Name="Stops" AllowFilteringByColumn="false">
<CommandItemSettings AddNewRecordText="Add New Stops" ShowAddNewRecordButton="true" />
<ParentTableRelation>
<%-- <telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID" />--%>
</ParentTableRelation>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditTask" EditText="Edit"
UpdateText="Update" CancelText="Cancel">
<HeaderStyle Width="20px" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn SortExpression="Name" HeaderText="Name" UniqueName="Name"
HeaderButtonType="TextButton" HeaderStyle-Width="15%" ItemStyle-Width="15%" DataField="tName">
<ItemTemplate>
<%# Eval("Name")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Width="250px" Text='<%# Eval("Name")%>'></asp:TextBox>
<asp:RequiredFieldValidator ID="requiredName" ControlToValidate="txtName"
CssClass="validationMessage" ErrorMessage="Name is required."
Text="* required" runat="server" Display="Dynamic"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Comment" HeaderText="Comment" UniqueName="Comment"
HeaderButtonType="TextButton" DataField="Comment">
<ItemTemplate>
<%# Eval("Comment")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtComment" TextMode="MultiLine" Rows="4" Width="250px" runat="server" Text='<%# Eval("Comment")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Address" HeaderText="Address"
DataField="Address" UniqueName="Address" HeaderButtonType="TextButton">
<ItemTemplate>
<%# Eval("Address")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtAddress" Width="250px" TextMode="MultiLine" Text='<%# Bind("Address") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Phone" HeaderText="Phone" UniqueName="Phone"
HeaderButtonType="TextButton" DataField="Phone">
<ItemTemplate>
<%# Eval("Phone")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPhone" Rows="4" Width="250px" runat="server" Text='<%# Eval("Phone")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Email" HeaderText="Email" UniqueName="Email"
HeaderButtonType="TextButton" DataField="Email">
<ItemTemplate>
<%# Eval("Email")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEmail" Rows="4" Width="250px" runat="server" Text='<%# Eval("Email")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="ManagerName" HeaderText="ManagerName" UniqueName="ManagerName"
HeaderButtonType="TextButton" DataField="ManagerName">
<ItemTemplate>
<%# Eval("ManagerName")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtManagerName" Rows="4" Width="250px" runat="server" Text='<%# Eval("ManagerName")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="NumberOfRooms" HeaderText="#Rooms" UniqueName="NumberOfRooms"
HeaderButtonType="TextButton" DataField="NumberOfRooms">
<ItemTemplate>
<%# Eval("NumberOfRooms")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtNumberOfRooms" Width="250px" Rows="4" runat="server" Text='<%# Eval("NumberOfRooms")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Merchandising" HeaderText="Merchandising" UniqueName="Merchandising"
HeaderButtonType="TextButton" DataField="Merchandising">
<ItemTemplate>
<%# Eval("Merchandising")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtMerchandising" Width="250px" Rows="4" runat="server" Text='<%# Eval("Merchandising")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Frequency" HeaderText="Frequency"
DataField="Frequency" UniqueName="Frequency" HeaderButtonType="TextButton">
<ItemTemplate>
<%# GetFrequencyName(Convert.ToInt32(Eval("FrequencyID"))) %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="drpFreq" runat="server" DataTextField="Name" DataValueField="ID"
AppendDataBoundItems="true">
<asp:ListItem Text="--Select--" Value="-1">
</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="DisplayOrder" HeaderText="Display Order" UniqueName="DisplayOrder"
HeaderButtonType="TextButton" HeaderStyle-Width="15%" ItemStyle-Width="15%" DataField="DisplayOrder">
<ItemTemplate>
<%# Eval("DisplayOrder")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDisplayOrder" runat="server" Width="250px" Text='<%# Eval("DisplayOrder")%>'></asp:TextBox>
<asp:RequiredFieldValidator ID="requiredDisplayOrder" ControlToValidate="txtDisplayOrder"
CssClass="validationMessage" ErrorMessage="Display Order is required."
Text="* required" runat="server" Display="Dynamic"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Delete" AllowFiltering="false">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" CommandName="DeleteStops" CommandArgument=' <%# Eval("ID") %>' runat="server" OnClientClick="javascript:if (!confirm('Are you sure you want to delete Stop?')) {
return false;
}">Delete</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</telerik:GridTableView>
</DetailTables>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText="Cancel" EditText="Edit"
UpdateText="Update" UniqueName="EditRoutes" ItemStyle-Width="5%">
<HeaderStyle Width="5%" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn SortExpression="Name" HeaderText="Name" UniqueName="RouteName"
HeaderButtonType="TextButton" HeaderStyle-Width="20%" ItemStyle-Width="20%" DataField="Name">
<ItemTemplate>
<%# Eval("Name")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtRouteName" runat="server" Text='<%# Eval("Name")%>'></asp:TextBox>
<asp:RequiredFieldValidator ID="requiredRouteName" ControlToValidate="txtRouteName"
CssClass="validationMessage" ErrorMessage="Name is required."
Text="* required" runat="server" Display="Dynamic"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Comment" HeaderText="Comment" UniqueName="Comment"
HeaderButtonType="TextButton" DataField="Comment">
<ItemTemplate>
<%# Eval("Comment")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtComment" TextMode="MultiLine" Rows="4" Width="250px" runat="server" Text='<%# Eval("Comment")%>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Delete" AllowFiltering="false">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" CommandName="Delete" CommandArgument=' <%# Eval("ID") %>' runat="server" OnClientClick="javascript:if (!confirm('Are you sure you want to delete route?')) {
return false;
}">Delete</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<SortExpressions>
<telerik:GridSortExpression FieldName="Name"></telerik:GridSortExpression>
</SortExpressions>
<CommandItemSettings AddNewRecordText="Add New Route" ShowAddNewRecordButton="true" />
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
And the code behind rowDrop event is
protected void radGridRoutes_RowDrop(object sender, GridDragDropEventArgs e)
{
GridDataItem RowDragged = e.DraggedItems.FirstOrDefault();
e.DraggedItems[0].GetDataKeyValue("DisplayOrder");
int OriginalID = Convert.ToInt32(RowDragged.GetDataKeyValue("ID"));
int OriginalOrder = Convert.ToInt32(RowDragged.GetDataKeyValue("DisplayOrder"));
int RouteID = Convert.ToInt32(RowDragged.GetDataKeyValue("RouteID"));
int DestID = Convert.ToInt32(e.DestDataItem.GetDataKeyValue("ID"));
int DestOrder = Convert.ToInt32(e.DestDataItem.GetDataKeyValue("DisplayOrder"));
UpdateOrder(OriginalID, OriginalOrder, DestID, RouteID);
}
Now the problem is i want to access the datakeyNames from the nested gridTableView. I am not able to figure that out. Please provide me suggestions how to get the ID,DisplayOrder,RouteID from nested gridtableview in rowdrop event. Currently it is giving null values to me.

Please try with the below code snippet.
ASPX
<telerik:GridTableView Name="Child" OnRowDrop="radGridRoutes_RowDrop" ClientSettings-AllowRowsDragDrop="true" DataKeyNames="ID,DisplayOrder,RouteID" Width="100%" runat="server" CommandItemDisplay="Top" Name="Stops" AllowFilteringByColumn="false">
ASPX.CS
protected void radGridRoutes_RowDrop(object sender, GridDragDropEventArgs e)
{
GridDataItem RowDragged = e.DraggedItems.FirstOrDefault();
if (RowDragged.OwnerTableView.Name == "Child")
{
// Row Dragged from child Grid
e.DraggedItems[0].GetDataKeyValue("DisplayOrder");
int OriginalID = Convert.ToInt32(RowDragged.GetDataKeyValue("ID"));
int OriginalOrder = Convert.ToInt32(RowDragged.GetDataKeyValue("DisplayOrder"));
int RouteID = Convert.ToInt32(RowDragged.GetDataKeyValue("RouteID"));
// You can also check same thing for Drop Item
int DestID = Convert.ToInt32(e.DestDataItem.GetDataKeyValue("ID")); int DestOrder = Convert.ToInt32(e.DestDataItem.GetDataKeyValue("DisplayOrder"));
UpdateOrder(OriginalID, OriginalOrder, DestID, RouteID);
}
}
Update 1:
If above code is not working then please try with the below code snippet.
Method 1:
ASPX
<telerik:GridTableView Name="Child" ClientDataKeyNames="ID,DisplayOrder,RouteID" OnRowDrop="radGridRoutes_RowDrop" ClientSettings-AllowRowsDragDrop="true" DataKeyNames="ID,DisplayOrder,RouteID" Width="100%" runat="server" CommandItemDisplay="Top" Name="Stops" AllowFilteringByColumn="false">
......
......
<ClientSettings>
<ClientEvents OnRowDragStarted="RowDragStarted" />
</ClientSettings>
JS Code
function RowDragStarted(sender, eventArgs) {
var tblvew = eventArgs.get_tableView().get_name();
if(tblvew == null || tblvew == undefined || tblvew != 'Child')
{
eventArgs.set_cancel(true);
}
}
OR
function RowDragStarted(sender, eventArgs) {
var route = eventArgs.getDataKeyValue("RouteID");
if(route == null || route == '')
{
eventArgs.set_cancel(true);
}
}
Let me know if any concern.

Related

INTran Not showing LotNumberNbr

Good day
I have made a new Grid to show data from INTran(PX.Objects.IN.INTran)
I see there is a LotSerialNbr in the INTran DAC. But when I make a new PXSelect I don't see it in the "ADD DATA FIELDS" on my page.
I add the Lot/Serial Nbr(LotSerialNbr) when loading stock on the Inventory Receipts.
I have also checked INRegister and INTranSplit both not show the Lot Serial Nbr?
using System;
using PX.Data;
using PX.Objects.IN;
using PX.Objects.SO;
namespace Test
{
public class StockTransfer : PXGraph<StockTransfer>
{
public PXSave<MasterTable> Save;
public PXCancel<MasterTable> Cancel;
public PXFilter<MasterTable > MasterView;
public PXFilter<INTran> DetailsView;
[Serializable]
public class MasterTable : IBqlTable
{
}
[Serializable]
public class DetailsTable : IBqlTable
{
}
public PXSelect<INRegister> Register;
public PXSelect<INTran> INTran;
public PXSelect<INTranSplit > INTranSplit ;
}
}
How can I get the Lot Serial number to show on the grid?
edit here is the ASPX:
<%# Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="ABIT1111.aspx.cs" Inherits="Page_ABIT1111" Title="Untitled Page" %>
<%# MasterType VirtualPath="~/MasterPages/FormDetail.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="JVDLocationTransfer.TransferGrap"
PrimaryView="MasterView"
>
<CallbackCommands>
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="MasterView" Width="100%" Height="100px" AllowAutoHide="false">
<Template>
<px:PXLayoutRule ID="PXLayoutRule1" runat="server" StartRow="True"></px:PXLayoutRule>
<px:PXTextEdit runat="server" ID="CstPXTextEdit1" DataField="UsrFROMLocation" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit2" DataField="UsrInventoryID" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit3" DataField="UsrInventoryItemDescription" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit4" DataField="UsrQty" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit5" DataField="UsrReasonCode" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit6" DataField="UsrSKU" />
<px:PXTextEdit runat="server" ID="CstPXTextEdit7" DataField="UsrUOM" /></Template>
</px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Width="100%" Height="150px" SkinID="Details" AllowAutoHide="false">
<Levels>
<px:PXGridLevel DataMember="INTran">
<Columns>
<px:PXGridColumn DataField="InventoryID" Width="70" />
<px:PXGridColumn DataField="LotSerialNbr" ></px:PXGridColumn></Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="150" />
<ActionBar >
</ActionBar>
</px:PXGrid>
</asp:Content>
The screen graph JVDLocationTransfer.TransferGrap declared in ASPX doesn't match the target StockTransfer graph. Also inexistent columns are declared on dataview like MasterView which points to empty DACs like MasterTable. Wizards functionality such as Add Data Field won't work properly in that context.

LinkedCommand & callbackcommand not doing anything

I'm trying to add an hyperlink from a field in a grid in a processing screen pointing to a custom object I made but it seems it doesnt do anything.
When I try to debug and set breakpoints it seems it doesnt even execute the code in my function.
I tried following this : How to create a hyperlink user field
And I tried to follow the example 3.4 in T200 (which is basically the same)
Here's my code :
public PXAction<ARRegister> ViewLettering;
[PXButton]
protected virtual void viewLettering()
{
ARRegister row = LinesPendingLettering.Current;
LELettering letPiece = PXSelect<LELettering,
Where<LELettering.letteringCD,
Equal<Required<LELettering.letteringCD>>>>
.Select(this, row.GetExtension<ARRegisterLeExt>().LettrageCD);
// Create instance of destination graph
LetteringAR graph = PXGraph.CreateInstance<LetteringAR>();
graph.Piece.Current = letPiece;
if (graph.Piece.Current != null)
{
throw new PXRedirectRequiredException(graph, true, Constantes.letteringPiece);
}
else
{
throw new PXException(Constantes.errNotFound);
}
}
#endregion
And the code of my page :
<%# Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="LE202001.aspx.cs" Inherits="Page_LE202001" Title="Untitled Page" %>
<%# MasterType VirtualPath="~/MasterPages/FormDetail.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="LE.ProcessAR"
PrimaryView="Filter"
>
<CallbackCommands>
<px:PXDSCallbackCommand Name="ViewLettering" Visible="False" DependOnGrid="grid" /></CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="Filter" Width="100%" Height="100px" AllowAutoHide="false">
<Template>
<px:PXLayoutRule StartColumn="True" ID="PXLayoutRule1" runat="server" StartRow="False"></px:PXLayoutRule>
<px:PXSelector CommitChanges="True" runat="server" ID="CstPXSelector2" DataField="BranchID" ></px:PXSelector>
<px:PXSelector AutoRefresh="True" CommitChanges="True" runat="server" ID="CstPXSelector1" DataField="AccountID" ></px:PXSelector>
<px:PXLayoutRule runat="server" ID="CstPXLayoutRule5" StartColumn="True" ></px:PXLayoutRule>
<px:PXNumberEdit runat="server" ID="CstPXNumberEdit3" DataField="TotalCredit" ></px:PXNumberEdit>
<px:PXNumberEdit runat="server" ID="CstPXNumberEdit4" DataField="TotalDebit" ></px:PXNumberEdit>
<px:PXLayoutRule runat="server" ID="CstPXLayoutRule6" StartColumn="True" />
<px:PXCheckBox CommitChanges="True" runat="server" ID="CstPXCheckBox7" DataField="ShowAll" ></px:PXCheckBox></Template>
</px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
<px:PXGrid SyncPosition="True" AutoAdjustColumns="True" ID="grid" runat="server" DataSourceID="ds" Width="100%" Height="150px" SkinID="Details" AllowAutoHide="false">
<Levels>
<px:PXGridLevel DataMember="LinesPendingLettering">
<Columns>
<px:PXGridColumn Type="CheckBox" AllowFilter="True" AllowCheckAll="True" CommitChanges="True" DataField="Selected" Width="30" ></px:PXGridColumn>
<px:PXGridColumn DataField="DocType" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="RefNbr" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="DocDesc" Width="200" ></px:PXGridColumn>
<px:PXGridColumn DataField="CuryOrigDocAmt" Width="100" ></px:PXGridColumn>
<px:PXGridColumn DataField="CuryID" Width="70" ></px:PXGridColumn>
<px:PXGridColumn LinkCommand="ViewLettering" DataField="LettrageCD" Width="70" ></px:PXGridColumn></Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="150" ></AutoSize>
<ActionBar >
</ActionBar>
</px:PXGrid>
</asp:Content>
The generic type parameter of PXAction has to be the same DAC as the primary view DAC.
The primary view attribute is set on PXDataSource element in the ASPX page:
<px:PXDataSource ID="ds" runat="server" PrimaryView="Filter">
In your graph or graph extension you can locate the primary view DAC:
public PXFilter<DAC> Filter;
Make sure the PXAction declaration is on the same DAC:
public PXAction<DAC> Action;
Adding an observation I had to this older thread, hoping it may help someone:
If you have everything setup as recommended but it is still not working, look carefully at your use of OrderBy in the View's delegate, specifically whether you defined an OrderBy<> directly on its PXSelectBase or used an OrderByNew<> later in
the delegate logic. Using OrderBy<> worked well, but using OrderByNew<> affected the functionality. Details:
The View:
[PXFilterable()]
public PXSelectOrderBy<DAC, OrderBy<Asc<DAC.field1>>> Records;
The Delegate:
protected virtual IEnumerable records()
{
PXSelectBase<DAC> cmd = new PXSelectJoinOrderBy<DAC,
InnerJoin<OtherDAC, On<DAC.field1, Equal<OtherDAC.field1>>>,
OrderBy<Desc<DAC.field1,
Desc<DAC.field2>>>>(this);
...
some filtering logic
...
// defining OrderByNew affected DependOnGrid/LinkCommand functionality
// cmd.OrderByNew<OrderBy<Desc<DAC.field1,
// Desc<DAC.field2>>>>();
foreach(DAC rec in cmd.Select())
yield return rec;
}
I am using 2018R1, Build 18.112.0019.

How to conditionally hide PXPanel inside an Acumatica screen?

I have the following use case:
Acumatica dropdown, which can have 2 or so values.
e.g.:
-If user selects option a, I need to show PXPanel(ID="panel1")
-If user selects option b, I need to show PXPanel(ID="panel2")
Those PXPanels are inside in one PXFormView, so they have one DataMember Like this :
<px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="Waybills">
<px:PXPanel ID="panel1" ..
<px:PXPanel ID="panel2" ..
</px:PXFormView>
Is it possible to conditionally show/hide PXPanels?
As RuslanDev said I can achieve the same effect with PXLayoutRule(GroupCaption), but in that case I can't set caption to 100%, it's equal the first column's width.
With PXPanel :
apsx :
<px:PXPanel ID="panel3" runat="server" Caption="Buyer (Receiver)" RenderStyle="Fieldset" AlreadyLocalized="False" DataMember="" >
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" ColumnWidth="XM" />
<px:PXSegmentMask CommitChanges="True" ID="edCustomerID" runat="server" DataField="CustomerID" DataSourceID="ds" />
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientTaxRegistrationID" runat="server" DataField="RecipientTaxRegistrationID" Enabled="False" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXCheckBox ID="edRecipientIsForeignCitizen" runat="server" DataField="RecipientIsForeignCitizen" AlreadyLocalized="False" Enabled="false"/>
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientName" runat="server" DataField="RecipientName" Enabled="False" AlreadyLocalized="False" DefaultLocale="" />
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientDestinationAddress" runat="server" DataField="RecipientDestinationAddress" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
</px:PXPanel>
With PXLayoutRule :
apsx :
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" GroupCaption="Buyer (Receiver)" StartGroup="true" ColumnSpan="3"/>
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXSegmentMask CommitChanges="True" ID="edCustomerID" runat="server" DataField="CustomerID" DataSourceID="ds" />
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientTaxRegistrationID" runat="server" DataField="RecipientTaxRegistrationID" Enabled="False" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXCheckBox ID="edRecipientIsForeignCitizen" runat="server" DataField="RecipientIsForeignCitizen" AlreadyLocalized="False" Enabled="false"/>
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientName" runat="server" DataField="RecipientName" Enabled="False" AlreadyLocalized="False" DefaultLocale="" />
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientDestinationAddress" runat="server" DataField="RecipientDestinationAddress" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
There is no option to hide entire PXPanel from business logic, except conditionally setting Visible to true or false for each input control placed within a PXPanel:
protected virtual void ARFinCharge_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARFinCharge fin = e.Row as ARFinCharge;
if (fin == null) return;
PXUIFieldAttribute.SetVisible<ARFinCharge.fixedAmount>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.FixedAmount);
PXUIFieldAttribute.SetVisible<ARFinCharge.lineThreshold>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.PercentWithThreshold);
PXUIFieldAttribute.SetVisible<ARFinCharge.minFinChargeAmount>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.PercentWithMinAmount);
}
For the PXLayoutRule approach, please use Aspx layout as below (the Customer selector has to span across the 3 columns underneath it):
<px:PXLayoutRule runat="server" StartRow="True" StartGroup="true" GroupCaption="Buyer (Receiver)" />
<px:PXSegmentMask CommitChanges="True" ID="edCustomerID" runat="server" DataField="CustomerID" />
<px:PXLayoutRule runat="server" Merge="True" />
<px:PXTextEdit ID="edRecipientTaxRegistrationID" Size="M" runat="server" DataField="RecipientTaxRegistrationID" Enabled="False" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXTextEdit ID="edRecipientName" runat="server" Size="M" DataField="RecipientName" Enabled="False" AlreadyLocalized="False" DefaultLocale="" />
<px:PXTextEdit ID="edRecipientDestinationAddress" Size="M" runat="server" DataField="RecipientDestinationAddress" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXLayoutRule runat="server" Merge="False" />
<px:PXCheckBox ID="edRecipientIsForeignCitizen" runat="server" DataField="RecipientIsForeignCitizen" AlreadyLocalized="False" Enabled="false"/>
<px:PXLayoutRule runat="server" EndGroup="true" />
Using PXFormView instead of PXPanel solved all the problems.

Create preview pane for grid

I want to create a preview pane below my custom grid on a tab, same as in other places it shows a preview below grid when I select any row.
I am using
PXGridWithPreview
And included
PreviewPanelTemplate
But, it is giving me below error
View AcumaticaActivities$Preview doesn't exist
I am not sure if I need to do any settings. Any suggestions?
Try to add PXPreviewAttribute to the selected view.
[PXPreview(typeof(TPrimaryView), typeof(TDacForPreview))]
public PXSelect<TPrimaryView,... AcumaticaActivities;
Here is the sample:
Graph code
public class SOPreview : PXGraph<SOPreview>
{
public PXCancel<SOOrder> Cancel;
[PXFilterable]
[PXPreview(typeof(SOOrder))]
public PXSelectJoin<SOOrder, LeftJoin<SOLine,
On<SOOrder.orderType, Equal<SOLine.orderType>,
And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>>> Orders;
public PXSelect<SOOrder,
Where<SOOrder.orderType, Equal<Current<SOOrder.orderType>>,
And<SOOrder.orderNbr, Equal<Current<SOOrder.orderNbr>>>>> Orders2;
public PXAction<SOOrder> View;
[PXUIField(DisplayName="View")]
[PXButton]
protected virtual IEnumerable view(PXAdapter a)
{
Orders2.AskExt();
return a.Get();
}
}
ASPX markup
<%# Page Language="C#" MasterPageFile="~/MasterPages/ListView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="C9101000.aspx.cs" Inherits="Page_C9101000" Title="Untitled Page" %>
<%# MasterType VirtualPath="~/MasterPages/ListView.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" PrimaryView="Orders" TypeName="GridWithPreview.SOPreview">
</px:PXDataSource>
<px:PXSmartPanel ID="pnlSODetail" runat="server" Style="z-index: 108;"
Caption="Sales Order Details" CaptionVisible="True"
Key="Orders2" ShowAfterLoad="false"
AutoRepaint="true"
AcceptButtonID="PXButtonOK">
<px:PXFormView ID="frmSO" runat="server" DataSourceID="ds" DataMember="Orders2" Width="100%"
Style="z-index: 100" TabIndex="17100">
<Template>
<px:PXLayoutRule runat="server" StartRow="True">
</px:PXLayoutRule>
<px:PXTextEdit ID="PXTextEdit1" runat="server" DataField="OrderType" Enabled="false">
</px:PXTextEdit>
<px:PXTextEdit ID="PXTextEdit2" runat="server" DataField="OrderNbr" Enabled="false">
</px:PXTextEdit>
<px:PXTextEdit ID="PXTextEdit3" runat="server" DataField="CustomerID" Enabled="false">
</px:PXTextEdit>
<px:PXTextEdit ID="PXTextEdit4" runat="server" DataField="OrderDesc" Enabled="false">
</px:PXTextEdit>
</Template>
</px:PXFormView>
<px:PXPanel ID="PXPanel1" runat="server" SkinID="Buttons">
<px:PXButton ID="pxBtnOK" runat="server" DialogResult="OK" Text="Close" />
</px:PXPanel>
</px:PXSmartPanel>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
<pxa:PXGridWithPreview ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100"
AllowPaging="True" AllowSearch="True" DataSourceID="ds" TabIndex="100"
GridSkinID="Inquire"
PreviewPanelStyle="z-index: 100; background-color: Window"
PreviewPanelSkinID="Preview">
<Levels>
<px:PXGridLevel DataKeyNames="OrderType,OrderNbr" DataMember="Orders">
<Columns>
<px:PXGridColumn DataField="OrderType">
</px:PXGridColumn>
<px:PXGridColumn DataField="OrderNbr">
</px:PXGridColumn>
<px:PXGridColumn DataField="CustomerID" Width="120px">
</px:PXGridColumn>
<px:PXGridColumn DataField="OrderDate" Width="90px">
</px:PXGridColumn>
<px:PXGridColumn DataField="Status">
</px:PXGridColumn>
<px:PXGridColumn DataField="OrderDesc" Width="200px">
</px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="200" />
<PreviewPanelTemplate>
<px:PXHtmlView ID="edPreviewCtrl" runat="server" DataField="OrderDesc" TextMode="MultiLine" MaxLength="50" Width="100%" Height="100px" SkinID="Label">
<AutoSize Container="Parent" Enabled="true"></AutoSize>
</px:PXHtmlView>
</PreviewPanelTemplate>
<GridMode AllowAddNew="False" AllowDelete="False" />
</pxa:PXGridWithPreview>
</asp:Content>

Update row in Gridview?

I have updated a row in Gridview but it is not working.
Here is my code :
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
//Label lbldeleteid = (Label)row.FindControl("Label1");
string bname= GridView1.DataKeys[e.RowIndex].Values["manufacturer"].ToString();
TextBox tbmanu = (TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[1];
var myString = tbmanu.ToString();
SqlCommand cmd = new SqlCommand("manu_upd",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#manufacturer", SqlDbType.NVarChar,100);
cmd.Parameters["#manufacturer"].Value = myString;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
BindData();
I got the following error :
Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.TextBox'.
here is my Grid view :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="manufacturer" ForeColor="#333333"
GridLines="None" Width="400px" BorderStyle="Double"
CellSpacing="3" Font-Bold="True" Font-Size="Small" ShowFooter="True"
ShowHeaderWhenEmpty="True" onrowdeleting="GridView1_RowDeleting"
onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"
onrowcancelingedit="GridView1_RowCancelingEdit"
AutoGenerateEditButton="True">
<AlternatingRowStyle BackColor="White"/>
<Columns>
<asp:TemplateField HeaderText="Number" ItemStyle-
HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lbnaumber" runat="server" Text='<%#
Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Manufacturer"
SortExpression="manufacturer">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("manufacturer") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbmanu" runat="server" Text='<%#
Bind("manufacturer") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<%--<asp:CommandField ShowEditButton="True" />--%>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF"/><FooterStyle BackColor="#507CD1"
Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"/>
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" /><SelectedRowStyle BackColor="#D1DDF1"
Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB"/>
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
When I change the index of my text box 1 to 3 it shows me below error :
Specified argument was out of the range of valid values.
Parameter name: index
When i change its index 3 to 2 it gives me below error :
Unable to cast object of type 'System.Web.UI.WebControls.DataControlLinkButton' to type 'System.Web.UI.WebControls.TextBox'.
I have one required field validator in my form but when I enable that validation update in grid view is not working.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
TextBox tbmanu1 = (TextBox)row.FindControl("tbmanu");
//or try
//TextBox tbmanu1= (TextBox)row.Cells[0].FindControl("tbmanu");
string myString = Convert.Tostring(tbmanu1.text);
cmd.Parameters["#manufacturer"].Value = myString;
}
Try wrapping your gridview in a asp:UpdatePanel and set the update mode to conditional.
Good Luck

Resources