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

Initialize RadGrid from clientside call

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Connie Sutton
Top achievements
Rank 1
Connie Sutton asked on 06 Jan 2009, 09:17 PM
Hi -

What is the proper way to bind a datasource to RadGrid in the codebehind using a value retrieved from a combobox on the client? 

<

telerik:RadComboBox ID="comboManagers"

 

 

Runat="server"

 

 

Height="115px"

 

Width="250px"

 

 

Skin="Sunset"

 

 

 

EnableLoadOnDemand="true"

 

 

 

AllowCustomText="True"

 

 

 

OnClientSelectedIndexChanged="LoadGrid"

 

 

 

>

 

 

 

<

 

 

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

</telerik:RadComboBox>

 

 

 

<telerik:RadGrid ID="RadGrid1"

 

 

 

runat="server" AllowPaging="True"

 

 

 

AllowSorting="True"

 

 

 

GridLines="None"

 

 

 

ShowGroupPanel="True"

 

 

 

OnNeedDataSource="RadGrid1_NeedDataSource"

 

 

 

>

 

 

 

...
function

 

 

LoadGrid(combo, eventargs) { 

 

var grid = $find("RadGrid1");

 

 

 

if (grid != null)

 

 

{

 

      var item = eventarqs.get_item();

 

 

       ???

 

  }

}

 


I have a routine in the codebehind which requires the data in item.get_value() for generating the datasource.

Thanks in advance for your help.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jan 2009, 05:09 AM
Hi Connie,

One suggestion would be to perform a PostBack from the client side and pass the SelectedItem from the RadComboBox as a parameter to the server side. Then in the RaisePostBack event bind the Grid with eventArgument value.

ASPX:
<telerik:RadComboBox id="RadComboBox1" runat="server"  OnClientSelectedIndexChanged="LoadGrid"  > 
          <Items> 
           <telerik:RadComboBoxItem  Text="SqlDataSource1" /> 
            <telerik:RadComboBoxItem  Text="SqlDataSource3" /> 
          </Items> 
        </telerik:RadComboBox> 

JS:
<script type="text/javascript" language="javascript"
function LoadGrid(sender, eventArgs) 
 var item = eventArgs.get_item().get_text(); 
 alert(item) 
 __doPostBack("<%= RadComboBox1.UniqueID %>", item); 
}  
</script> 


CS:
 protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument) 
    { 
        if (eventArgument !=null
        { 
            RadGrid1.DataSourceID = eventArgument; 
        } 
 
    } 


Thanks
Shinu
Tags
Grid
Asked by
Connie Sutton
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or