ASPxGridview 未定义

发布于 2024-10-19 08:19:25 字数 4492 浏览 2 评论 0原文

我有一个基本的 1 表网格。我有一个名为“分支类型”的字段。分支机构类型只能是公司或特许经营。当我单击 ASPxgridview 行上的编辑按钮时,我想显示和隐藏编辑表单上的字段,具体取决于它是什么分支类型。因此,如果是公司,我想显示经理字段并隐藏所有者字段。当分支类型为特许经营时,我希望在编辑表单上显示所有者字段并隐藏经理字段。所有详细信息都可以显示在网格视图上,但在编辑表单上,我想强制用户仅填写适用的字段。

如果您看下面:

这基本上就是我在加载编辑表单时想要实现的目标:

  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);
}"

但是当调用它时,我收到以下错误:

Microsoft 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 从 AutoID 更改为 Inherit,将 Static 更改为 Predictable,并且每个场景都不起作用,并且仍然呈现: 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 ..但一点运气都没有。我已经给了你我声明 httphandler 的 web.config 设置,那么你还建议我做什么来让它工作呢?

这是我的网络配置:

部分启用配置 所采用的安全认证方式 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" />

很抱歉问了这么长的问题。顺便说一句,这是使用 DevExpress Gridview。 devexpress 的人帮不了我,花了 1 天的时间才回答问题,所以现在已经持续了差不多一周了……

谢谢 维尔纳

I have a basic 1 table grid. I have a field called Branch type. The branch type can only be Corporate or Franchise. When i click on the edit button on the ASPxgridview row , i would like to display and hide fields on the edit form, depending on what Branch Type it is. So if it is Corporate i would like to Display the Manager field and Hide the Owner field. When the branch type is Franchise then I would like the Owner field to be displayed and the Manager field to be hidden on the edit form. all details can show on the grid view but on the edit form i would like to force the user to only fill in applicable fields.

If you look below:

this is basically what i want to achieve on loading the edit form :

  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;
    }

}

and then depending on selecting Corporate or Franchise in the "StoreOwnershipID" field i will use the client side script to enable or disable the additional fields.

I have done some research as well, and i came up with the following code:

SelectedIndexChanged="function(s, e) {      
var value = s.GetValue();
    if(value == 4)
        GridViewStores.GetEditor("OwnerName").SetVisible(true);
    else
         GridViewStores.GetEditor("OwnerName").SetVisible(false);
}"

but when this is called i get the following error:

Microsoft JScript runtime error: 'GridViewStores' is undefined

I have added the HTTPhandler in the web.config:

<httpModules>
  <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>

and

<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>

as you can see below i have inserted the ClientInstanceName,

i have changed the ClientIDMode from AutoID to Inherit to Static to Predictable and each scenario does not work and still renderes : Microsoft JScript runtime error: 'ASPxGridview' is undefined.

below my gridview tag

<dx:ASPxGridView ID="ASPxGridView" runat="server" AutoGenerateColumns="False" 
    ClientIDMode="Predictable" DataSourceID="SqlDataSource1" KeyFieldName="S_ID" 
    ClientInstanceName="ASPxGridView">

i have now even tried creating a new page with just a sqldatasource and gridview with the storetype field as acombobox and including the javascript as mentioned in my previous posts.. and no luck at all. i have given you my web.config settings where i declared the httphandler, so what else do you suggest i do to get this working?

here is my webconfig:

section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->

section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

    <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" />

sorry for the looong question. by the way this is using DevExpress Gridview. The guys from devexpress cant help me and tak 1 day to answer a question, so its been going on for almost a week now...

Thank you
Werner

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

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

发布评论

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

评论(1

逆光下的微笑 2024-10-26 08:19:25

Java 脚本是区分大小写的语言。因此,如果 ClientInstanceName 设置为 ASPxGridView,则您的代码应为:

ASPxGridView.GetEditor("OwnerName").SetVisible(true);

我看到错误消息包含“ASPxGridview;”标识符。这意味着您的代码包含 ASPxGridview 标识符,但您应该使用 ASPxGridView (基于您的标记)。另外,我认为这段代码是错误的:

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;
    }

您将 ManagerID 对象的 Enabled 属性两次设置为相同的值。请检查一下。我没什么可补充的。如果这没有帮助,请告诉我支持中心票证 ID,如果可能,请附上页面的源代码(cs 和 aspx)和 web.config。我们会尽力帮助您。

更新:我在支持中心找到了您的问题并进行了解答。希望这有帮助。

The Java Script is a case sensitive language. So, if the ClientInstanceName is set to ASPxGridView, your code should be:

ASPxGridView.GetEditor("OwnerName").SetVisible(true);

I see that the error message contains the 'ASPxGridview;' identifier. It means that your code contains the ASPxGridview identifier but you should use the ASPxGridView (based on your mark up). Also, I believe that this code is wrong:

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;
    }

You set the Enabled property of the ManagerID object twice to the same value. Please check it. I have nothing to add. if this does not help, please let me know the support center ticket ID and if possible attach the source code of the page (cs and aspx) and web.config there. We will try to help you.

Update: I have found your question in the support center and answered it. Hope, this helps.

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