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
105
Get value from dropdown provider in grid
posted

I have a cascading dropdown scenario in the webdatagrid.  In order to populate the second dropdown, I need to value of the selecteditem in the first dropdown.  The following javascript firest on the CellEditing_EnteredEditMode event and gives me a value, but the value does not appear to be for the dropdown on the correct row.

 

 if (args._editor._id.indexOf("ddlTeams") > -1) {
                var editorID = sender._editorProviders._items[1]._editor._id;
                var val = getWDDLValue(editorID);
                args._editor.loadItems(val);
            }

function getWDDLValue(wddlID) {
           var wddl = $find(wddlID);
            var item = wddl.get_items().getItem(wddl.get_selectedItemIndex());
            if (item != null) {
                return item.get_value();
            } else {
            return null;
            }
        }

I need the value, not the text since the query that populates the second dropdown requires it.

Any help appreciated!
-Lee


 

 

Parents
No Data
Reply
  • 8160
    posted

    Hello Lee,

    the following javascript should return the provider's value:

    function WebDataGrid1_Editing_CellValueChanged(sender, eventArgs)
    {
     ///<summary>
     ///
     ///</summary>
     ///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param>
     ///<param name="eventArgs" type="Infragistics.Web.UI.CellValueChangedEventArgs"></param>

     //Add code to handle your event here.

        var value = eventArgs.get_cell().get_value();
        alert(value);
    }

    Also you will have to specify DataKeyFields and ValueField for the WebDropDownProvider:

     <ig:DropDownProvider ID="WebDataGrid1_DropDownProvider1">
                        <EditorControl ClientIDMode="Predictable" DataSourceID="SqlDataCategories" DataKeyFields="CategoryID"
                            ValueField="CategoryID" TextField="CategoryName" DropDownContainerMaxHeight="200px"
                            EnableAnimations="False" EnableDropDownAsChild="False">
                            <DropDownItemBinding TextField="CategoryName" ValueField="CategoryID"></DropDownItemBinding>
                            <ClientEvents ValueChanged="ValueChanged" />
                        </EditorControl>
                    </ig:DropDownProvider>

    Please let me know if this is working for you

Children