Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to implement cascaded combo box columns in ASPxGridView without using templates

$
0
0

The example illustrates how to create an editable grid with cascaded combobox columns. The implementation of the example includes the handling of manual callbacks and providing items for appropriate arguments.
By default, the combobox column uses a datasource that displays all records to show a user Text values instead of record keys.

Question Comments

Added By: Deborah Carter at: 5/9/2014 3:45:18 AM    

I looked at the code below and it looks like what I have.  The page just never gets to it.  Here is the complete asp page:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="mnt_Person.aspx.vb" Inherits="mnt_Person" %>

<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <script type="text/javascript">
   // <![CDATA[
      var lastServiceDivNo = null;
      function OnServiceDivNoChanged(cmbServiceDivisionNm) {
          if (grid.GetEditor("ServiceAreaNm").InCallback())
              lastServiceDivNo = cmbServiceDivisionNm.GetValue().toString();
          else
              grid.GetEditor("ServiceAreaNm").PerformCallback(cmbServiceDivisionNm.GetValue().toString());
      }
      function OnEndCallback(s, e) {
          if (lastServiceDivNo) {
              grid.GetEditor("ServiceAreaNm").PerformCallback(lastServiceDivNo);
              lastServiceDivNo = null;
          }
      }
   // ]]>
   </script>
   <asp:Label ID="Label2" runat="server" CssClass="pageheader" Width="100%" Text="Supervisor Maintenance"></asp:Label>
   <br />
   <dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
       DataSourceID="SqlDataSource1" KeyFieldName="Person_Key">
       <Columns>
          <dx:GridViewCommandColumn ShowClearFilterButton="True" ShowNewButton="True"
               VisibleIndex="1">
           </dx:GridViewCommandColumn>
           <dx:GridViewDataTextColumn FieldName="Person_Key" VisibleIndex="2">
               <EditFormSettings Visible="False" />
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor_No" VisibleIndex="3">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceDivisionNm" VisibleIndex="4">
               <PropertiesComboBox DataSourceID="SqlDataSource2" TextField="ServiceDivisionNm" EnableSynchronization="False"
                   ValueField="ServiceDivisionNo">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) {OnServiceDivNoChanged(s); }"></ClientSideEvents>
                </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceAreaNm" VisibleIndex="5">
               <PropertiesComboBox EnableSynchronization="False">
               <ClientSideEvents EndCallback="OnEndCallback"></ClientSideEvents>
               </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
                       <dx:GridViewDataTextColumn FieldName="TransNoPrefix" VisibleIndex="8">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor" VisibleIndex="9">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataCheckColumn FieldName="IsActive" VisibleIndex="10">
           </dx:GridViewDataCheckColumn>
       </Columns>
       <SettingsEditing Mode="Batch">
       </SettingsEditing>
       <Settings ShowFilterRow="True" />
       <SettingsCommandButton>
           <ClearFilterButton Text="Clear">
           </ClearFilterButton>
       </SettingsCommandButton>
       <SettingsDataSecurity AllowDelete="False" />
   </dx:ASPxGridView>
   

   <asp:SqlDataSource ID="SqlDataSource2" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceDivisionNo], [ServiceDivisionNm] FROM [dim_Organization]">
   </asp:SqlDataSource>
   
   <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceAreaNo], [ServiceAreaNm] FROM [dim_Organization] WHERE ServiceDivisionNo = ? ">
       <SelectParameters>
           <asp:Parameter Name="?" />
       </SelectParameters>
   </asp:SqlDataSource>

   <asp:SqlDataSource ID="SqlDataSource1" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       
       SelectCommand="SELECT dbo.dim_Person.Person_Key, dbo.dim_Person.Supervisor_No, dbo.dim_Person.TransNoPrefix, dbo.dim_Person.Supervisor, dbo.dim_Person.IsActive, dbo.dim_Organization.ServiceAreaNm, dbo.dim_Organization.ServiceDivisionNm FROM dbo.dim_Person INNER JOIN dbo.dim_Organization ON dbo.dim_Person.ServiceDivisionNo = dbo.dim_Organization.ServiceDivisionNo AND dbo.dim_Person.ServiceAreaNo = dbo.dim_Organization.ServiceAreaNo WHERE (dbo.dim_Person.IsActive = 1)">
     
   </asp:SqlDataSource>
   

</asp:Content>

Added By: Larry (DevExpress Support) at: 5/9/2014 5:31:02 AM    Hello Deborah,

So, I have created a separate ticket on your behalf to process your inquiry more effectively:

How to implement cascaded combo box columns in ASPxGridView without using templates

Please refer to it for further correspondence.

 

Added By: S Abowitz at: 8/25/2014 10:26:50 AM    

I don't understand how this code work for new rows if in the grid_celleditorinitialize sub, if checks If (Not grid.IsNewRowEditing) Then before getting the filter value, so how does the second combo prefill for new rows after country is selected?

Please explain,


Viewing all articles
Browse latest Browse all 7205

Trending Articles