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

Select RadGrid Row when Templated Combo Selected

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 21 Nov 2008, 11:50 AM
I'm looking for a code sample that shows how to automatically select a row of the grid when a RadCombo that is part of a templated column is clicked or selected.   I have a templated column that contains a radcombo control.  If you click outside of the combo, the row gets selected (good).  If the user clicks the combo to dropdown, the row doens't get selected.  this causes confusion for the user because they expect the row to get selected.

Any advice on how to do this?


Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Nov 2008, 12:21 PM
Hi Randy,

Try with the following approach and see if it helps.

ASPX:
<telerik:GridTemplateColumn  UniqueName="TempCol" HeaderText="TempCol" > 
                     <ItemTemplate> 
                         <telerik:RadComboBox ID="RadComboBox1" runat="server"
                         </telerik:RadComboBox> 
                     </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            int RowIndex = item.ItemIndex; 
            RadComboBox combo = (RadComboBox)item["TempCol"].FindControl("RadComboBox1"); 
            combo.Attributes.Add("OnClick", "return Select('" + RowIndex + "');"); 
            
        } 
    } 

JS:
<script type="text/javascript"  language="javascript" > 
 function Select(RowIndex) 
 { 
  alert(RowIndex) 
   
  $find("RadGrid1").get_masterTableView().get_dataItems()[RowIndex].set_selected("true"); 
 } 
</script> 


Thanks
Princy.

0
Randy
Top achievements
Rank 1
answered on 21 Nov 2008, 01:09 PM
that seems to work.  thanks.  The only thing is that I want it to behave as though the user clicked the row.  Meaning that normally if a user selects the row, the other rows are unselected.  I also have some ajax calls occuring that update a panel when the user clicks a row.  Anyway to plug into the grid rowselect?
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Randy
Top achievements
Rank 1
Share this question
or