<tr>
<td>
Second Product Category:
</td>
<td colspan="2">
<dx:ASPxDropDownEdit ID="ASPxDropDownEdit4" AllowUserInput="False" ClientInstanceName="txtSecondCateName"
runat="server" CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx"
Spacing="0" SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" Width="100%">
<DropDownWindowTemplate>
<dx:ASPxGridView ID="ASPxGridView2" KeyFieldName="Oid" ClientInstanceName="grid2"
DataSourceID="XpoDataSource5" runat="server" CssFilePath="~/App_Themes/DevEx/{0}/styles.css"
CssPostfix="DevEx" OnCustomDataCallback="ASPxGridView2_CustomDataCallback" Width="100%">
<Columns>
<dx:GridViewCommandColumn ShowInCustomizationForm="True" ShowSelectCheckbox="True"
VisibleIndex="0">
<ClearFilterButton Visible="True">
</ClearFilterButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataColumn FieldName="Name" Caption="Name" VisibleIndex="1">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="Oid" Caption="Oid" Visible="false"></dx:GridViewDataColumn>
</Columns>
<ClientSideEvents SelectionChanged="function(s,e){GetID2(s,e);}" />
<Settings ShowFilterRow="True" ShowGroupPanel="True" />
<Images SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
<LoadingPanelOnStatusBar Url="~/App_Themes/DevEx/GridView/StatusBarLoading.gif">
</LoadingPanelOnStatusBar>
<LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
</LoadingPanel>
</Images>
<ImagesFilterControl>
<LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
</LoadingPanel>
</ImagesFilterControl>
<Styles CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx">
<Header ImageSpacing="5px" SortingImageSpacing="5px">
</Header>
<LoadingPanel ImageSpacing="5px">
</LoadingPanel>
</Styles>
<StylesEditors ButtonEditCellSpacing="0">
<ProgressBar Height="21px">
</ProgressBar>
</StylesEditors>
</dx:ASPxGridView>
</DropDownWindowTemplate>
<ButtonStyle Width="13px">
</ButtonStyle>
</dx:ASPxDropDownEdit>
</td>
</tr>
脚本
function GetID2(s, e) {
grid2.GetSelectedFieldValues("Oid", function (value) {
txtSecondCateName.SetKeyValue(value);
});
grid2.GetSelectedFieldValues("Name", function (value) {
txtSecondCateName.SetText(value);
});
}
后台代码
protected void ASPxGridView2_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
{
if (e.Parameters != "")
{
string[] arr = e.Parameters.Split(',');
string stroid = "";
string strname = "";
for (int i = 0; i < arr.Length; i++)
{
strname = strname + arr[i] + ',';
//Terminology aw = s.FindObject<Terminology>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Oid=?", oid));
//stroid += "," + oid;
//if (aw != null)
//{
// strname += "," + aw.Name;
//}
}
//if (stroid != "")
// stroid = stroid.Substring(1);
//if (strname != "")
// strname = strname.Substring(1);
//e.Result = stroid + "|" + strname;
e.Result = strname;
}
}
if (!string.IsNullOrEmpty(r.PSecondCategory))
{
(ASPxNavBar1.Groups[0].FindControl("ASPxDropDownEdit4") as ASPxDropDownEdit).KeyValue = r.PSecondCategoryOid;
(ASPxNavBar1.Groups[0].FindControl("ASPxDropDownEdit4") as ASPxDropDownEdit).Value = r.PSecondCategory;
ASPxDropDownEdit edi = (this.ASPxNavBar1.Groups[0].FindControl("ASPxDropDownEdit4") as ASPxDropDownEdit);
ASPxGridView ag = edi.FindControl("ASPxGridView2") as ASPxGridView;
string str = r.PSecondCategoryOid;
string[] arr = str.Split(',');
for (int j = 0; j < ag.VisibleRowCount; j++)
{
for (int i = 0; i < arr.Length; i++)
{
if (ag.GetRowValues(j, "Oid") != null)
if (ag.GetRowValues(j, "Oid").ToString() == arr[i].ToString())
ag.Selection.SelectRow(j);
}
}
}
else
{
(ASPxNavBar1.Groups[0].FindControl("ASPxDropDownEdit4") as ASPxDropDownEdit).KeyValue = null;
(ASPxNavBar1.Groups[0].FindControl("ASPxDropDownEdit4") as ASPxDropDownEdit).Value = "";
}
本文详细介绍了如何使用ASPxDropDownEdit组件来实现产品二级类别的选择功能,包括前端界面配置、后台代码逻辑及JavaScript交互。通过具体实例展示了如何通过组件选择多个类别并获取其OID和名称。
 ASPxGridView&spm=1001.2101.3001.5002&articleId=6283663&d=1&t=3&u=c7096bb88fd14d01ac555535e6ddc9f5)
200

被折叠的 条评论
为什么被折叠?



