Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1740
How to display DropDownList in RowEditingTemplate
posted

How can I make a column as DropDownList using DropDownProvider in RowEditingTemplate? The sample shows the DropDownList in edit mode within the cell https://ko.infragistics.com/samples/aspnet/data-grid/dropdown-editors

Parents
  • 2501
    Suggested Answer
    posted

    Hello Ram,

    Thank you for posting your inquiry to the Infragistics ASP.Net forums.  To embed a WebDropDown in the WebDataGrid RowEditTemplate, add the WebDropDown control to the RowEditTemplate for the Column where you want the DropDownList to display.  Set the DisplayMode to "DropDownList", the TextField to the Name of the Column to display in the WebDropDown, the ValueField to the Column Key which the WebDropDown is bound to, and EnableDropDownAsChild to "true".  The Z-Index for the DropDown needs to be set to a higher value or the DropDownList will not display properly.  To do this, you can set the Z-Index in the Client-Side Initialize event to a new Z-Index value.

    In the Behaviors of the EditingCore, under ColumnSettings, set the ColumnKey to the Column where the WebDropDown was added. 

    In the RowEditTemplate under the ClientBindings, the RowEditingClientBinding for the Column with the WebDropDown needs to use the $find command to locate the WebDropDown control so its current value may be retrieved and to also set its new value.

    The following Markup Code is based on three of the columns from the sample in our Samples Browser which you had referenced in your post.  This code will demonstrate how to embed a WebDropDown in a WebDataGrid RowEditTemplate:

    <ig:WebDataGrid ID="dg" runat="server" Height="500px" width="800px" DataSourceID="Orders"  
          DataKeyFields="OrderID" AutoGenerateColumns="False" OnRowUpdating="dg_RowUpdating">
     <Columns>
      <ig:BoundDataField DataFieldName="OrderID" Key="OrderID">
       <Header Text="Order ID" />
      </ig:BoundDataField>   
      <ig:BoundDataField DataFieldName="ContactName" Key="CustomerID">
       <Header Text="Contact Name" />
      </ig:BoundDataField>
      <ig:BoundDataField DataFieldName="ShippingCompany" Key="ShipperID">
       <Header Text="Shipper" />
      </ig:BoundDataField> 
     </Columns>                  
     <Behaviors>
       <ig:EditingCore>
      <Behaviors>
       <ig:CellEditing Enabled="true" >
        <ColumnSettings>
          <ig:EditingColumnSetting ColumnKey="ShipperID" />
        </ColumnSettings>
         </ig:CellEditing>                         
       <ig:RowDeleting Enabled="true" />
       <ig:RowEditingTemplate CancelButton="buttonCancel" OKButton="buttonOK">
        <ClientBindings>
         <ig:RowEditingClientBinding ColumnKey="OrderID" ControlID="control_OrderID"
          GetValueJavaScript="$get({ClientID}).value"
          SetValueJavaScript="$get({ClientID}).value={value}" />
         <ig:RowEditingClientBinding ColumnKey="CustomerID" ControlID="control_ContactName"
          GetValueJavaScript="$get({ClientID}).value"
          SetValueJavaScript="$get({ClientID}).value={value}" />
         <ig:RowEditingClientBinding ColumnKey="ShipperID" ControlID="control_Shipper"
          GetValueJavaScript="$find({ClientID}).get_currentValue()"
          SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" />
        </ClientBindings>
        <Template>
         <div style="background-color:white;border:1px solid black; height:auto; width:auto">
          OrderID:
          <asp:TextBox ID="control_OrderID" runat="server"/>
          <br />
          ContactName:
          <asp:TextBox ID="control_ContactName" runat="server"/>
          <br />
          Shipper:
          <ig:WebDropDown ID="control_Shipper" DisplayMode="DropDownList"DataSourceID="Shippers" 
                TextField="CompanyName" ValueField="ShipperID" runat="server" Width="200px" 
                 EnableDropDownAsChild="true" ClientEvents-Initialize="setZIndex"
    DropDownItemBinding-TextField="CompanyName" DropDownItemBinding-ValueField="ShipperID">
          </ig:WebDropDown>
          <br />
          <asp:Button ID="buttonOK" runat="server" OnClientClick="return" Text="OK"
           UseSubmitBehavior="False" />
          <asp:Button ID="buttonCancel" runat="server" CausesValidation="False"
           OnClientClick="return" Text="Cancel" UseSubmitBehavior="False" />
         </div>
        </Template>
       </ig:RowEditingTemplate>
       <ig:RowAdding Enabled="False">
        <EditModeActions EnableOnActive="True" EnableOnKeyPress="True"
         MouseClick="Single" />
       </ig:RowAdding>                                                                                     
       </Behaviors>
       </ig:EditingCore>
       <ig:Activation />
       <ig:RowSelectors />
       <ig:Selection RowSelectType="Single" />
     </Behaviors>
    </ig:WebDataGrid>

    The following code snippet is an example on how to set the zIndex for the DropDownList of the WebDropDown:

    function setZIndex(sender, args) {
         sender.behavior.set_zIndex(100000);
    }

    Please let me know if this information is helpful or if you have any questions or need further assistance.

    Thank you.

    Sincerely,
    Mike D.
    Developer Support Engineer
    Infragistics
    www.infragistics.com/support

Reply Children