如何在主从GridView中获取详细信息网格的选定行?

发布于 2024-09-08 15:47:33 字数 2918 浏览 5 评论 0 原文

我在获取详细网格的选定行值时遇到问题。我在弹出控件中有主从网格,并且工作正常。我还启用了启用选择以具有复选框,但是当我尝试在按钮的 ClientSideEvents 上运行 GetSelectedFieldValues 时,它总是返回“0”。我做错了什么,我找不到它?

这是详细网格:

 AutoGenerateColumns="False"

CssFilePath="~/App_Themes/Aqua/{0}/styles.css"

 CssPostfix="Aqua" 

                            OnBeforePerformDataSelect="gv_ParameterTempD_BeforePerformDataSelect"

ClientInstanceName="gvC_ParameterTempD">

 

ShowSelectCheckbox=“真” VisibleIndex="0">

 ;

                                

Caption="Detay Kodu" 字段名称=“PrmDetailCode”

 VisibleIndex="0">

                                

                                

Caption="Seçim Adı" FieldName="PrmDetailName"

 VisibleIndex="2">

                                

                                

Caption="Seçim Adı(Grup)"

 FieldName="PrmDetailNameG"

VisibleIndex="3">

 ;

                                

Caption="Seçim Adı(Stok)"

 FieldName="PrmDetailNameS"

VisibleIndex="4">

 ;

                                

Caption="Grup Seçimi Yapan"

 FieldName="PrmGroupSelector"

VisibleIndex="5">

 ;

                                

Caption="Stok Seçimi Yapan"

 FieldName="PrmStokSelector"

VisibleIndex="6">

 ;

                            

这是按钮:

 

这是js脚本:

函数 ShowCellValue(值) {

 var value = condition.GetText();

    警报(值。长度); // 这里返回“0”

    如果(值!=“”)

    {

        var newValue = ' ' + 值 + 值 + ' = ';

        条件.SetText(newValue);

    }

    别的

    {

        for(var i = 0; i 

我不知道我做错了什么,

感谢您的帮助

I'm having a problem on getting the selected rows values of a detail grid. I have master-detail grid in a popup control and it works fine. I also enabled the enable selection to have checkboxes but when i try to run GetSelectedFieldValues on ClientSideEvents of a button it always returns "0". What do i do wrong, i couldn't find it?

Here is the detail grid:

                            AutoGenerateColumns="False"

CssFilePath="~/App_Themes/Aqua/{0}/styles.css"

                            CssPostfix="Aqua" 

                            OnBeforePerformDataSelect="gv_ParameterTempD_BeforePerformDataSelect"

ClientInstanceName="gvC_ParameterTempD">

                                <dxwgv:GridViewCommandColumn

ShowSelectCheckbox="True"
VisibleIndex="0">

                                </dxwgv:GridViewCommandColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Detay Kodu"
FieldName="PrmDetailCode"

                                    VisibleIndex="0">

                                </dxwgv:GridViewDataTextColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Seçim Adı"
FieldName="PrmDetailName"

                                    VisibleIndex="2">

                                </dxwgv:GridViewDataTextColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Seçim Adı(Grup)"

                                    FieldName="PrmDetailNameG"

VisibleIndex="3">

                                </dxwgv:GridViewDataTextColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Seçim Adı(Stok)"

                                    FieldName="PrmDetailNameS"

VisibleIndex="4">

                                </dxwgv:GridViewDataTextColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Grup Seçimi Yapan"

                                    FieldName="PrmGroupSelector"

VisibleIndex="5">

                                </dxwgv:GridViewDataTextColumn>

                                <dxwgv:GridViewDataTextColumn

Caption="Stok Seçimi Yapan"

                                    FieldName="PrmStokSelector"

VisibleIndex="6">

                                </dxwgv:GridViewDataTextColumn>

                            </Columns>

And this is the button:

                <ClientSideEvents Click="function(s,e)

                {

                    pcc_Question.Hide();

                    gvC_ParameterTempD.GetSelectedFieldValues('PrmDetailName;PrmDetailNameG;PrmDetailNameS',ShowCellValue);

                }"

                />

            </dxe:ASPxButton>

and this is the jsscript:

function ShowCellValue(values) {

    var value = condition.GetText();

    alert(values.length); // here it returns "0"

    if(value != "")

    {

        var newValue = ' ' + value + values + ' = ';

        condition.SetText(newValue);

    }

    else

    {

        for(var i = 0; i < values.length; i ++) {

            value += values[i];

        }

        condition.SetText(value);

    }



}

I don't know what i do wrong,

Thanks for the help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

放赐 2024-09-15 15:47:34

我根据您的描述创建了一个示例项目,并且运行良好。可以从以下位置下载:

http://www.devexpress.com /Support/Center/ViewIssue.aspx?issueid=Q220495

I have created a sample project based on your description and it works fine. It is available to download from:

http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q220495

欢烬 2024-09-15 15:47:33

我的假设是否正确,即该按钮驻留在同一个 DetailRowTemplate 容器中?无论如何,有必要访问详细 GridView 对象的正确实例。为此,请将网格的 ClientInstanceName 属性设置为动态值。这应该允许您访问正确的网格实例并获取选定的行值。示例代码位于:

http://www.devexpress.com /Support/Center/ViewIssue.aspx?issueid=Q90007

Am I right in my assumption that the button is residing in the same DetailRowTemplate container? Anyway, it is necessary to access the proper instance of the detail GridView object. To do this, set the grid's ClientInstanceName property to a dynamic value. This should allow you to access the proper grid instance and fetch selected row values. A sample code is available at:

http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q90007

心的位置 2024-09-15 15:47:33

我在运行时设置数据源,但我不调用 DataBind 方法,因为它使详细网格的 BeforePerformDataSelect 执行多个操作。

此代码设置主网格数据源并绑定它:

受保护的无效
gv_Answers_CustomCallback(对象
发件人,
ASPxGridViewCustomCallbackEventArgs e)
{

 ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();
        masterKey = e.参数;

        if (masterKey!= "")
        {
            man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
            gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
            gv_Answers.DataBind();

            清除();

        }
    }

此代码用于设置详细网格的数据源:

受保护的无效
gv_ParameterTempD_BeforePerformDataSelect(对象
发送者、EventArgs e)
{

 ASPxGridViewDetailGrid = 发送者为 ASPxGridView;

        masterKey =DetailGrid.GetMasterRowKeyValue().ToString();
        man.Add(new SqlOperatorEquality("MAND_CONF_PRM_D_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));

        DetailGrid.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmDTempCollection),man);
    }

I'm setting the DataSource at Runtime but i do not call DataBind method, because it makes BeforePerformDataSelect of the Detail Grid to perform more than one.

This code set the master grids datasource and bind it:

protected void
gv_Answers_CustomCallback(object
sender,
ASPxGridViewCustomCallbackEventArgs e)
{

        ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();
        masterKey = e.Parameters;

        if (masterKey != "")
        {
            man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
            gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
            gv_Answers.DataBind();

            man.Clear();

        }
    }

And this code is for setting the datasource of the detail grid:

protected void
gv_ParameterTempD_BeforePerformDataSelect(object
sender, EventArgs e)
{

        ASPxGridView detailGrid = sender as ASPxGridView;

        masterKey = detailGrid.GetMasterRowKeyValue().ToString();
        man.Add(new SqlOperatorEquality("MAND_CONF_PRM_D_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));

        detailGrid.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmDTempCollection),man);
    }
2024-09-15 15:47:33

我看到您在 CustomCallback 事件处理程序中设置了主网格的数据源。尝试将 masterKey 值缓存在 Session 变量中,并不仅在 CustomCallback 事件处理程序中而且在 Page_Init 方法中设置网格的 DataSource:

protected void Page_Init(object sender, EventArgs e) {
    if(Session["masterKey"] == null)
      return;
    ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();

            masterKey = Session["masterKey"].ToString();

            if (masterKey != "")
            {
                man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
                gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
                man.Clear();
            }

    }


    protected void Page_Load(object sender, EventArgs e) {
                gv_Answers.DataBind();
    }

这有帮助吗?

I see that you set the master grid's DataSource in the CustomCallback event handler. Try to cache the masterKey value in a Session variable and set the grid's DataSource not only in the CustomCallback event handler but also in the Page_Init method:

protected void Page_Init(object sender, EventArgs e) {
    if(Session["masterKey"] == null)
      return;
    ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();

            masterKey = Session["masterKey"].ToString();

            if (masterKey != "")
            {
                man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
                gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
                man.Clear();
            }

    }


    protected void Page_Load(object sender, EventArgs e) {
                gv_Answers.DataBind();
    }

Does this help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文