大家好...你能帮我解决我的问题吗?我有 dx:ASPxGridView 包含 4 列“productId”、“ProductName”、“Brand”和“Unit”。我可以获取 3 第一列的值,但我想获取“Unit”列的项目文本取决于“productId”值。productId 列是组合框,其中包含 3 列“ProductId、ProductNam、Brand”
背后的代码
function OnClick(s, e) {
var item = listBox.GetSelectedItem();
memo.SetText(item.GetColumnText(2));
memo4.SetText(item.GetColumnText(0));
proId.SetText(item.GetColumnText(0));
memo2.SetText(item.GetColumnText(1));
setTimeout(function () { grid.FocusEditor(3); }, 1);
}
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" ClientInstanceName="grid" OnCellEditorInitialize="grid_CellEditorInitialize" RightToLeft="True" Width="1293px" Theme="Metropolis" >
<SettingsEditing Mode="Inline">
</SettingsEditing>
<Settings ShowFilterRow="True" />
<SettingsBehavior AllowSelectSingleRowOnly="true" AllowSelectByRowClick="true" />
<SettingsCommandButton>
<ShowAdaptiveDetailButton ButtonType="Image"></ShowAdaptiveDetailButton>
<HideAdaptiveDetailButton ButtonType="Image"></HideAdaptiveDetailButton>
</SettingsCommandButton>
<Columns>
<dx:GridViewDataComboBoxColumn Caption="ProductId" fieldName="ProId" Name="listBox"
Visible="true" VisibleIndex="1">
<PropertiesComboBox TextField="ProdName"
ValueField="ProductId"
DataSourceID="ProdNumDataSource"
ClientInstanceName="listBox">
<Columns>
<dx:ListBoxColumn Caption="Product Id" FieldName="ProductId" Name="ColProductid" />
<dx:ListBoxColumn Caption="Productc Name" FieldName="ProdName" Name="ColProductName" />
<dx:ListBoxColumn Caption="Brand" FieldName="BrandName" />
</Columns>
</PropertiesComboBox>
<SettingsHeaderFilter>
<DateRangePickerSettings EditFormatString="" />
</SettingsHeaderFilter>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataTextColumn Caption="ProductName" Visible="true" VisibleIndex="2" >
<SettingsHeaderFilter>
<DateRangePickerSettings EditFormatString=""></DateRangePickerSettings>
</SettingsHeaderFilter>
<PropertiesTextEdit ClientInstanceName="memo2"></PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Brand" FieldName="brand" VisibleIndex="3">
<PropertiesTextEdit ClientInstanceName="memo">
</PropertiesTextEdit>
<SettingsHeaderFilter>
<DateRangePickerSettings EditFormatString="" />
</SettingsHeaderFilter>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Quantity" FieldName="quantity" VisibleIndex="4">
<SettingsHeaderFilter>
<DateRangePickerSettings EditFormatString="" />
</SettingsHeaderFilter>
</dx:GridViewDataTextColumn>
<dx:GridViewDataComboBoxColumn Caption="Unit" fieldName="Unit" name="memo4"
Visible="true" VisibleIndex="5">
<PropertiesComboBox TextField="UnitName"
ValueField="UnitId"
DataSourceID="UnitsDataSource"
ClientInstanceName="memo4">
<Columns>
<dx:ListBoxColumn Caption="UnitId Id" FieldName="UnitId" Name="ColProductid" />
<dx:ListBoxColumn Caption="UnitName" FieldName="UnitName" Name="ColProductUnit" />
</Columns>
</PropertiesComboBox>
<SettingsHeaderFilter>
<DateRangePickerSettings EditFormatString="" />
</SettingsHeaderFilter>
</dx:GridViewDataComboBoxColumn>
</Columns>
</dx:ASPxGridView>
<asp:SqlDataSource ID="ProdNumDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:phoenixConnectionString %>" SelectCommand="SELECT Products.ProductId, Products.ProdName, Brands.BrandName FROM Products INNER JOIN Brands ON Products.Brand = Brands.BrandId where ProductId >0">
</asp:SqlDataSource>
<asp:SqlDataSource ID="invoice" runat="server" ConnectionString="<%$ ConnectionStrings:phoenixConnectionString %>" SelectCommand="SELECT Bills.AutoDocNum, BillDetails.ProId, BillDetails.quantity, BillDetails.ModuleQuantity, BillDetails.PriceCost, BillDetails.SecondUnit, BillDetails.Unit, BillDetails.module, BillDetails.brand FROM BillDetails INNER JOIN Bills ON Bills.DocNum = BillDetails.DocNum ">
</asp:SqlDataSource>
<asp:SqlDataSource ID="UnitsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:phoenixConnectionString %>" SelectCommand="SELECT Units.UnitName, ProductsDetail.UnitId, ProductsDetail.productId, ProductsDetail.ItemNo FROM Units INNER JOIN ProductsDetail ON Units.UnitId = ProductsDetail.UnitId">
</asp:SqlDataSource>
Protected Sub grid_CellEditorInitialize(ByVal sender As Object, ByVal e As ASPxGridViewEditorEventArgs)
con.Open()
If e.Column.FieldName = "ProId" Then
Dim editor As ASPxComboBox = TryCast(e.Editor, ASPxComboBox)
editor.ClientSideEvents.SelectedIndexChanged = "function(s, e) {OnClick(s);}"
Dim products = grid.GetSelectedFieldValues("ProId")
End If
con.Close()
End Sub