我有一个基本的1表网格。我有一个叫分支类型的字段。分行类型只能是企业或特许经营。当我点击ASPxgridview行上的编辑按钮时,我想显示并隐藏编辑表单上的字段,具体取决于它的分支类型。所以如果是公司,我想显示经理字段和隐藏所有者字段。当分支类型是特许经营时,我希望显示所有者字段并将管理员字段隐藏在编辑表单上。所有细节都可以在网格视图中显示,但在编辑表单上我想强制用户只填写适用的字段。ASPxGridview undefined
如果你看看下面:
这基本上就是我想要实现的加载编辑表单:
protected void ASPxGridViewStores_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
{
if (!ASPxGridViewStores.IsEditing || e.Column.FieldName != "StoreOwnershipID") return;
if(e.KeyValue == DBNull.Value || e.KeyValue == null) return;
object val = ASPxGridViewStores.GetRowValuesByKeyValue(e.KeyValue, "S_ID");
if(val == DBNull.Value) return;
int StoreOwnershipID = (Int32)val;
if (StoreOwnershipID == 4)
{ ASPxComboBox ManagerID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ManagerID");
ManagerID.Enabled = true;
ASPxComboBox ContactID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ContactID");
ManagerID.Enabled = true;
}
else
{ ASPxComboBox ManagerID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ManagerID");
ManagerID.Enabled = false;
ASPxComboBox ContactID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ContactID");
ManagerID.Enabled = false;
}
}
,然后根据在“StoreOwnershipID”现场我会选择企业或加盟使用客户端脚本来启用或禁用其他字段。
我做了一些研究,以及,我想出了下面的代码:
SelectedIndexChanged="function(s, e) {
var value = s.GetValue();
if(value == 4)
GridViewStores.GetEditor("OwnerName").SetVisible(true);
else
GridViewStores.GetEditor("OwnerName").SetVisible(false);
}"
但是当这个叫我收到以下错误:
微软JScript运行时错误:“GridViewStores “未定义
我已经添加在web.config中的HttpHandler:
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
和
<system.webServer>
<modules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
,你可以看到下面我插入ClientInstanceName,
我已经从自动识别改变的ClientIDMode以继承为静态可预测的和每个方案不起作用,仍然renderes:Microsoft JScript中的运行时错误:'ASPxGridview'未定义。
我的gridview的标签下面
<dx:ASPxGridView ID="ASPxGridView" runat="server" AutoGenerateColumns="False"
ClientIDMode="Predictable" DataSourceID="SqlDataSource1" KeyFieldName="S_ID"
ClientInstanceName="ASPxGridView">
我现在甚至试图创建一个只有一个SqlDataSource和GridView用的storetype字段acombobox一个新的页面,包括JavaScript作为我在以前的文章中提到..并没有一切都好运。我已经给你我的web.config设置,我宣布了httphandler,那么你还有什么建议我做这个工作?
这里是我的webconfig:
部分使使用 ASP.NET来识别传入的用户的安全身份验证模式的配置 。 - > 部分启用配置 如果/在执行请求期间发生未处理的错误 时该怎么办。具体而言, 它使开发人员能够配置html错误页面 以代替错误堆栈跟踪进行显示。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
<httpHandlers>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" validate="false" />
</httpHandlers>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
遗憾的looong问题。顺便说一句,这是使用DevExpress Gridview。从DevExpress的家伙不能帮助我和德1天回答一个问题,所以它已经持续了现在将近一个星期......
谢谢 沃纳