我在获取详细网格的选定行值时遇到问题。我在弹出控件中有主从网格,并且工作正常。我还启用了启用选择以具有复选框,但是当我尝试在按钮的 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
发布评论
评论(4)
我根据您的描述创建了一个示例项目,并且运行良好。可以从以下位置下载:
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
我的假设是否正确,即该按钮驻留在同一个 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
我在运行时设置数据源,但我不调用 DataBind 方法,因为它使详细网格的 BeforePerformDataSelect 执行多个操作。
此代码设置主网格数据源并绑定它:
此代码用于设置详细网格的数据源:
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:
And this code is for setting the datasource of the detail grid:
我看到您在 CustomCallback 事件处理程序中设置了主网格的数据源。尝试将 masterKey 值缓存在 Session 变量中,并不仅在 CustomCallback 事件处理程序中而且在 Page_Init 方法中设置网格的 DataSource:
这有帮助吗?
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:
Does this help?