AspxClientGridView AddNewRow,如何在组合框之后更改值(使用selectedindexchan

本文关键字:selectedindexchan 使用 之后 AddNewRow 组合 AspxClientGridView | 更新日期: 2023-09-27 18:31:17

我是DevExpress的新手。

我设法显示"AddNewRow",但我希望当用户在组合框中选择一个项目时,其他字段会自动填充。

设法恢复了组合框项目的值(其 ID),因此我获得了所有匹配的值(通过一个返回 ID 后面的值的方法,所以描述、价格......

问题是我无法更改"AddNewRow"中其他字段的值。如何在这些字段中分配检索到的值?

这是我的aspx代码:

<dx:ASPxGridView OnCustomCallback="ASPxGridViewArticles_CustomCallback" OnInit="ASPxGridViewArticles_Init" ID="ASPxGridViewArticles" ClientInstanceName="ClientGridArticles" runat="server" Width="1399px" AutoGenerateColumns="False" KeyFieldName="RefArticle" OnRowUpdating="ASPxGridViewArticles_RowUpdating">                          
                        <Columns>
                            <%--<dx:GridViewCommandColumn EditButton-Visible="true" NewButton-Visible="true"></dx:GridViewCommandColumn>--%>
                            <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                <EditButton Visible="true"/>
                                <HeaderCaptionTemplate>
                                    <dx:ASPxHyperLink ID="btnNew" runat="server" Text="New">
                                        <ClientSideEvents Click="function (s, e) { ClientGridArticles.AddNewRow();}" />
                                    </dx:ASPxHyperLink>
                                </HeaderCaptionTemplate>
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataComboBoxColumn Name="RefArticle" FieldName="RefArticle">
                                <PropertiesComboBox TextField="Description" ValueField="Id" DataSourceID="ListArticlesDS">
                                    <ClientSideEvents SelectedIndexChanged="function(s, e) {                                           
                                        var t = s.GetValue();
                                        ClientGridArticles.PerformCallback('ComboBoxArticles' + ';' + s.GetValue());
                                        }"></ClientSideEvents>
                                </PropertiesComboBox>
                                <EditFormSettings VisibleIndex="1" />
                            </dx:GridViewDataComboBoxColumn>
                            <dx:GridViewDataColumn Name="Description" FieldName="Description">
                                <EditFormSettings VisibleIndex="2" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="Quantity" FieldName="Quantity">
                                <EditFormSettings VisibleIndex="3" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="PU" FieldName="PU">
                                <EditFormSettings VisibleIndex="4" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="PUCurrency" FieldName="PUCurrency">
                                <EditFormSettings VisibleIndex="5" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="Discount" FieldName="Discount">
                                <EditFormSettings VisibleIndex="6" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="Amount" FieldName="Amount">
                                <EditFormSettings VisibleIndex="7" />
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataColumn Name="AmountCurrency" FieldName="AmountCurrency">
                                <EditFormSettings VisibleIndex="8" />
                            </dx:GridViewDataColumn>
                        </Columns>
                        <SettingsBehavior AllowSort="false" AllowDragDrop="false" />
                    </dx:ASPxGridView>
                    <asp:ObjectDataSource ID="ListArticlesDS" runat="server" SelectMethod="Helper_Get_RefArticles2" TypeName="AlphaNetworks_PRO_DevExpress.Helpers.Helper"></asp:ObjectDataSource>

这是我的C#代码:

protected void ASPxGridViewArticles_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        var args = e.Parameters.Split(';');
        if (args[0] == "ComboBoxArticles") 
        {
            if (args[1] == "New Article")
            {
            }
            else
            {
                int id = Convert.ToInt32(args[1]);
                Article article = Helper.Helper_Get_ArticleById(id);;
            }
        }
    }

AspxClientGridView AddNewRow,如何在组合框之后更改值(使用selectedindexchan

请考虑使用服务器端 ASPxGridView.InitNewRow 事件为新行提供默认值。

ASPxGridView - 添加新行时如何实现级联组合框中还描述了一种方法。您可以在其中处理 CellEditorInitialize 事件并检查 IsNewRowEditing 属性以检测是否编辑了新行。

相关文章:
  • 没有找到相关文章