检查一个aspxgridview主 - 细节是否在客户端检查任何行 [英] Checking if a aspxgridview Master-Detail has any row checked in Client Side

查看:248
本文介绍了检查一个aspxgridview主 - 细节是否在客户端检查任何行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查是否在主数据AspxGridView中检查了任何行。

I need to check if there is any row checked in a Master-Detail AspxGridView.

与主人可以使用

grid.GetSelectedRowCount()>0

但是如何使用JS检查它的细节行?

But how can I check it with the detail rows using JS?

提前感谢

推荐答案

要完成此操作,您需要为每个客户端分配唯一的ClientInstanceName详细网格,然后使用分配的ClientInstanceName访问客户端上的特定详细网格,后者又应包含主网格行ID部分,即第一行的detailGrid_1,第二行的detailGrid_2等等。

to accomplish this you need to assign a unique ClientInstanceName to each detail grid and then access that particular detail grid on client side using the assigned ClientInstanceName, which in turn should include the master's grid row ID part, ie detailGrid_1 for the first row, detailGrid_2 for the second and so on.

要将ClientInstanceName分配给每个详细信息网格,您需要将自定义的Page_Init处理程序添加到详细信息网格中,作为codebehind中处理程序中的ClientInstanceName集。

To assign the ClientInstanceName to each detail grid you need to add a custom Page_Init handler to the detail grid as the set ClientInstanceName in that handler in codebehind.

因此,网络定义可能如下所示:

So, the web definition may look like:

<dx:ASPxGridView ID="masterGrid" runat="server" ClientInstanceName="masterGrid">
...
<Templates>
   <DetailRow>
      <dx:ASPxGridView ID="detailGrid" runat="server" OnInit="detailGrid_OnInit">
         ...
      </dx:ASPxGridView>
   </DetailRow>
</Templates>
...
</dx:ASPxGridView>

然后在codebehind中:

Then in codebehind:

protected void detailGrid_OnInit(object sender, EventArgs e) {
    ASPxGridView detailGridView = (ASPxGridView)sender;
    GridViewDetailRowTemplateContainer templateContainer =
                   (GridViewDetailRowTemplateContainer)detailGridView.NamingContainer;
    detailGridView.ClientInstanceName = string.Format("detailGrid_{0}",
                                             templateContainer.VisibleIndex);
}

然后在客户端在你的事件处理程序(你没有提到哪个事件您正在尝试检查细节网格是否选择了某些行),您需要获取主网格的行ID,并手动构建详细网格的客户端实例名称,例如:

Then on client side in your event handler (you didn't mention upon which event you were trying to check if detail grid has some rows selected) you need to obtain the master grid's row ID and construct a client instance name for your detail grid manually, e.g.:

eval('detailGrid_' + master_grids_row_id).

或者您可以将其以现成的形式传递给JS甚至如下面的文章建议的处理程序。

or you may pass it in a ready-made form to JS even handler like the article below suggests.

一旦您具有正确的detailGrid Client实例名称,您可以调用以下JS方法:

Once you have the correct detailGrid Client instance name you can call the following JS method:

detailGrid_XX.GetSelectedKeysOnPage();

有关代码示例,请参阅DX支持文章: https://www.devexpress.com/Support/Center/Question/Details/Q450479

See this DX support article for some code samples: https://www.devexpress.com/Support/Center/Question/Details/Q450479

HTH

这篇关于检查一个aspxgridview主 - 细节是否在客户端检查任何行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆