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

Call grid event on the radcombo selectedindex changed event

12 Answers 313 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
unnikkannan m
Top achievements
Rank 1
unnikkannan m asked on 16 Dec 2009, 09:41 AM
Hai Everyone,

First of all thanking for the great support from the Telerik team.


I need to fire the detail table databind event of the rad grid on
the selected index changed of the radcombo Box.
Please give the solution.


Regards
Unni.


12 Answers, 1 is accepted

Sort by
0
unnikkannan m
Top achievements
Rank 1
answered on 17 Dec 2009, 06:33 AM
Hai Telerik Team,

 I didn't got a reply yet.
Please give me a solution

Regards
Unni
0
Veselin Vasilev
Telerik team
answered on 18 Dec 2009, 02:06 PM
Hello unnikkannan m,

What is the exact problem? Please give us more details, for example where is the combobox - out of the grid or in the Edit template?

Kind regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
unnikkannan m
Top achievements
Rank 1
answered on 28 Dec 2009, 08:40 AM
Hai Veselin Vasilev ,

      I'm having combo and grid in the page. the combo works as parent child. When selecting one item from the combo its details is filled in the next combo . When the detail combo item is selected its detail is filled. Same as the detail table of the radgrid. I did the same on the radgrid with the detail table.
       What i need now is that when i'm selecting the combo its detail combo should be filled and at the same time the detail table should be expanded and show the details.ie. the selection index changed of the combo should call the detail table databind of the radgrid.
i hope you might have understand my problem.


Regards
Unni
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Dec 2009, 10:39 AM
Hello Unni,

You can try out the following code to achieve the required:

c#:
 protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        if (RadComboBox1.Text == "CustomText1"
        { 
            RadComboBox2.DataSourceID = "SqlDataSource1"
            RadComboBox2.DataTextField = "ComboDetails"
        } 
 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
            if(dataItem["ColumnUniqueName"].Text == MyRadComboBox.SelectedItem.Text) 
                  dataItem.Expanded = true// this will trigger the DetailTableDataBind event of the grid          
             
        } 
    } 

Thanks
Princy.
0
unnikkannan m
Top achievements
Rank 1
answered on 30 Dec 2009, 06:34 AM
Hai Princy,
    Thank you very much for the  reply.
    It fires the grid detail table event but the detail table is not expanding and it doesn't show the detail table.
What would be the problem ? suggest me a solution.



Regards
Unni

0
Princy
Top achievements
Rank 2
answered on 30 Dec 2009, 08:03 AM
Hello Unni,
 
This can probably happen if you are explicitly calling the Rebind() method for the grid in any event(like RadGrid_PreRender) that get triggered after the DetaiTableDataBind event . So make sure that the Rebind() call is avoided or used with a condition.

Thanks
Princy.
0
unnikkannan m
Top achievements
Rank 1
answered on 30 Dec 2009, 08:36 AM
Hai Princy,


 Thanks once again. the issue was solved.
 
One more thing.. I had shown the detail table corresponding to the dropdown. From the detail table thus shown how could we select an item for  the  corresponding dropdown same as we have done earlier.
eg..
dropdown                                                                                                                           grid
                                                                                             Name              Total          Present
   Institution->Building A --->Block A-->Cell1                         Building A          3               1
                                                       -->Cell2                                         BlockA        1             1 
                                                                                                                        Cell1         1        1
                                     -->Block B-->Cell3                                           BlockA        2             0
                                                                                            Building B
                                                     -->Cell4

                 -->Building B --->Block C--->Cell5
                                                        --->Cell6
                                      --->Block D

                -->Building C--->Block E
                                    --->Block F

this is the actual requirement when i'm selecting  a building the detail table of that corresponding building is shown and when i'm selecting the block  of that building from combo i need to show the detail table of that block and so on.

    Now I had done for the the building with your help. I need to know how to call the detail table of the detail table




Regards
Unni.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 31 Dec 2009, 02:32 PM
Hello Unnikkannan,

You can try the following code snippet in order to expand the item at different levels in a hierarchical grid based on the selected item in a RadComboBox:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="true" runat="server"
     <MasterTableView HierarchyLoadMode="client" DataSourceID="SqlDataSource1" Name="Master"
         <DetailTables> 
              <telerik:GridTableView DataSourceID="SqlDataSource2" Name="Detail"  runat="server"
                  <DetailTables> 
                      <telerik:GridTableView Name="subDetail" DataSourceID="SqlDataSource3" runat="server"
                      .... 
NB: Set the HierarchyLoadMode property of the tableviews to Client
c#:
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    {         
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.OwnerTableView.Name == "Master"
            { 
                if (item["MasterColumnUniqueName"].Text == RadComboBox1.SelectedItem.Text) 
                { 
                    item.Expanded = true
                } 
            } 
            
            if (item.OwnerTableView.Name == "Detail"
            { 
                if (item["DetailColumnUniqueName"].Text == RadComboBox1.SelectedItem.Text) 
                { 
                    item.Expanded = true
                    item.OwnerTableView.ParentItem.Expanded = true
                } 
            } 
        } 
    } 

Happy New Year!!
-Shinu.
0
unnikkannan m
Top achievements
Rank 1
answered on 05 Jan 2010, 10:07 AM
Hai Shinu Master,

      Thank you very much..... It helped me a lot..
Belated New Year Wishes..
Unni
0
Rahul Barpha
Top achievements
Rank 1
answered on 05 May 2010, 10:03 AM
Hello,

I Have a problen related to "telerik:GridDropDownColumn" ,
i have two GridDropDownlist in telerik radgrid when i going edit mode
 i want to call first GridDropDown selectindexchange event and get selected value and pass to second GridDropDown

SqlDataSource as a difault value.

0
Princy
Top achievements
Rank 2
answered on 05 May 2010, 11:15 AM
Hello Rahul,

There is no default event for editor changes in grid columns. But you can attach events in the ItemCreated event of Telerik RadGrid after getting reference to the control.

CS:
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            DropDownList list = (e.Item as GridEditableItem)["DropDownColumn1"].Controls[0] as DropDownList; 
            list.AutoPostBack = true
            list.SelectedIndexChanged += new System.EventHandler(this.list_SelectedIndexChanged); 
        } 
    } 
    private void list_SelectedIndexChanged(object sender, System.EventArgs e) 
    { 
        DropDownList dropDownFirst = (DropDownList)sender; 
        GridEditFormItem editForm = (GridEditFormItem)dropDownFirst.NamingContainer; 
        DropDownList dropDownSecond = (DropDownList)editForm["DropDownColumn2"].Controls[0]; 
        dropDownSecond.SelectedValue = dropDownFirst.SelectedValue; 
    } 


You can also go through the following link to know more on this:
Attaching event for an auto-generated grid column editor

Regards,
Princy.
0
Rahul Barpha
Top achievements
Rank 1
answered on 06 May 2010, 06:00 AM
Hi Princy

Thank you very much. It helped me a lot.
Tags
ComboBox
Asked by
unnikkannan m
Top achievements
Rank 1
Answers by
unnikkannan m
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Princy
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Rahul Barpha
Top achievements
Rank 1
Share this question
or