This is a migrated thread and some comments may be shown as answers.

Dependent GridDropDownColumn Issue

3 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas Sonnenschein
Top achievements
Rank 2
Thomas Sonnenschein asked on 22 Jan 2009, 12:27 PM
Hello everybody,

  I have two problems with dependent GridDropDownColumns in my project.
I have to Lists in my RadGrid. The second list  has to display a sub-set of data, which is based on the selection in the first list

For this problem I found a nearly working solution in the Post under this Link.
This Post refers to a Demo on the Telerik page: Demo

If I realize it like in the demo, it works fine in all rows except the last one. Here the second list is not refreshed, even if all relevant events were fired like in all other rows. This Problem occurs in the Telerik Demo, too.

The second problem is, that it didn't work on insert either.

The technical stuff:
I Use RadControls for ASPNET AJAX Q3 2008 with VS 2008 SP1 under WinXP SP3.

With a bit more searching I found a second demo from Telerik with the same problem:
http://demos.telerik.com/aspnet-ajax/Grid/Examples/Programming/AccessingCellsAndRows/DefaultCS.aspx
This one has RadComboBoxes instead of DropDownLists for the GridDropDownColumns like my coding.



Greetings
  Thomas

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Jan 2009, 02:20 PM
Hello Thomas,

Thank you for pointing this discrepancy.

Please use the following workaround:
void list_SelectedIndexChanged(object sender, EventArgs e) 
    GridEditableItem editedItem = (sender as DropDownList).NamingContainer as GridEditableItem; 
 
    GridDropDownListColumnEditor editor = editedItem.EditManager.GetColumnEditor("ddlQuantity"as GridDropDownListColumnEditor; 
 
    DropDownList ddList = editedItem["ddlQuantity"].Controls[0] as DropDownList; 
 
    DataTable table = GetRelatedRecords("SELECT OrderID, Quantity FROM [Order Details] WHERE OrderID = " + (editedItem["ddlOrderID"].Controls[0] as DropDownList).SelectedValue);         
    ddList.ClearSelection(); 
    ddList.DataSource = table; 
    editor.DataSource = table; 
    ddList.DataBind(); 
 
    RadGrid1.Controls.Add(new LiteralControl("<b>The available options for 'Quantites in stock' has been changed</b>")); 

As a sign of gratitude I updated your Telerik points.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Thomas Sonnenschein
Top achievements
Rank 2
answered on 19 Feb 2009, 02:11 PM
Hello Daniel,

  sorry for the late answer, but I haven't found the time to check your workyround until now.
So I tried now your solution and it works.

I found another solution in the meantime. I used in my first implementation an objectDataSource for my DDls and set a control parameter in DataBind and SelectedIndexChanged. This works fine for new entries and if you edit the last entry in the grid, but for all other entries it does not work.
Then I found your Demo, that does not work on new entries and the last entry in the grid.
So I combined the two solutions.

Here is my code (odsGroups is the datasource of the dependant DDL):
    private void list_SelectedIndexChanged (object sender, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox rcbMaterialGroupStandard = (RadComboBox) sender; 
        String smgsSelectedValue = rcbMaterialGroupStandard.SelectedValue.ToString (); 
 
        //first reference the edited grid item through the NamingContainer attribute 
        GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem; 
 
        //the dropdown list will be the first control in the Controls collection of the corresponding cell 
        RadComboBox ddList = editedItem["standardTitle"].Controls[0] as RadComboBox; 
 
        // change the data source for ContactTitle with custom code here 
        MaterialGroups mgData = new MaterialGroups (smgsSelectedValue, uConnectedUser); 
 
        ddList.DataSource = mgData.dsData.Tables[0]; 
        ddList.DataBind (); 
 
        odsGroups.SelectParameters.Clear (); 
        odsGroups.SelectParameters.Add ("sStandard", TypeCode.String, smgsSelectedValue); 
        odsGroups.DataBind (); 
    } 
 

Greetings
  Thomas
0
Accepted
Daniel
Telerik team
answered on 23 Feb 2009, 05:16 PM
Hello Thomas,

Thank you for sharing the solution with us. I'm confident that it will be useful for the community.

Keep up the good work!

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Thomas Sonnenschein
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Thomas Sonnenschein
Top achievements
Rank 2
Share this question
or