开发者

ASPxGridview undefined

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 java开发者_如何学Goscript 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜