我在获取详细网格的选定行值时遇到问题。我在弹出控件中有master-detail网格,它工作正常。我还启用了启用选项以具有复选框,但是当我尝试在按钮的ClientSideEvents上运行GetSelectedFieldValues时,它总是返回“0”。我做错了什么,我找不到了?
这是详细网格:
AutoGenerateColumns="False"
CssFilePath = “〜/ App_Themes文件/水族/ {0} /styles.css”
CssPostfix="Aqua" OnBeforePerformDataSelect="gv_ParameterTempD_BeforePerformDataSelect"
ClientInstanceName = “gvC_ParameterTempD” >
<dxwgv:GridViewCommandColumn
ShowSelectCheckbox = “真” VisibleIndex = “0” &GT;
</dxwgv:GridViewCommandColumn> <dxwgv:GridViewDataTextColumn
Caption =“Detay Kodu” FieldName =“PrmDetailCode”
VisibleIndex="0"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn
Caption =“SeçimAdı” FieldName =“PrmDetailName”
VisibleIndex="2"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn
Caption =“SeçimAdı(Grup)”
FieldName="PrmDetailNameG"
VisibleIndex = “3” &GT;
</dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn
Caption =“SeçimAdı(Stok)”
FieldName="PrmDetailNameS"
VisibleIndex = “4” &GT;
</dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn
Caption =“GrupSeçimiYapan”
FieldName="PrmGroupSelector"
VisibleIndex = “5” &GT;
</dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn
Caption =“StokSeçimiYapan”
FieldName="PrmStokSelector"
VisibleIndex = “6” &GT;
</dxwgv:GridViewDataTextColumn> </Columns>
这是按钮:
<ClientSideEvents Click="function(s,e) { pcc_Question.Hide(); gvC_ParameterTempD.GetSelectedFieldValues('PrmDetailName;PrmDetailNameG;PrmDetailNameS',ShowCellValue); }" /> </dxe:ASPxButton>
这是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); } }
我不知道我做错了什么,
感谢您的帮助
答案 0 :(得分:0)
我是否认为按钮位于同一个DetailRowTemplate容器中?无论如何,有必要访问详细的GridView对象的正确实例。为此,请将网格的ClientInstanceName属性设置为动态值。这应该允许您访问正确的网格实例并获取所选的行值。示例代码位于:
http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q90007
答案 1 :(得分:0)
我在运行时设置DataSource,但我没有调用DataBind方法,因为它使Detail Grid的BeforePerformDataSelect执行多个。
此代码设置主网格数据源并绑定它:
受保护的虚空 gv_Answers_CustomCallback(对象 发件人, 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(); } }
此代码用于设置详细信息网格的数据源:
受保护的虚空 gv_ParameterTempD_BeforePerformDataSelect(对象 发件人,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); }
答案 2 :(得分:0)
我看到你在CustomCallback事件处理程序中设置了主网格的DataSource。尝试将masterKey值缓存在Session变量中,并且不仅要在CustomCallback事件处理程序中设置网格的DataSource,还要在Page_Init方法中设置:
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();
}
这有帮助吗?
答案 3 :(得分:0)
我已根据您的描述创建了一个示例项目,并且工作正常。可从以下网址下载:
http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q220495