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

binding a radgrid using javascript/ajax

2 Answers 340 Views
Grid
This is a migrated thread and some comments may be shown as answers.
diane
Top achievements
Rank 1
Veteran
diane asked on 27 Oct 2011, 03:42 PM
I am trying to bind a radgrid after a button click event using Javacript ...here the code below ... 


aspx page: on page load this is empty

 

<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" >

 

 

<MasterTableView>

 

 

<Columns>

 

 

 

<

 

telerik:GridTemplateColumn >

 

 

 

 

 

<HeaderStyle CssClass="header" Width="5%" Height="7%" />

 

 

 

 

 

<HeaderTemplate>

 

 

 

 

 

<asp:CheckBox ID="cbSelectAll" runat="server" onClick="checkedAll(this);"></asp:CheckBox>

 

 

 

 

 

</HeaderTemplate>

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:CheckBox ID="chkBox" AutoPostBack="false" runat="server" ></asp:CheckBox>

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

<

 

telerik:GridBoundColumn UniqueName="SalesNo" DataField="SalesNo" HeaderText=" Sales Number" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" >

 

 

<HeaderStyle CssClass="header" />

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

javacript:

//results is data returned from a web service call using ajax

 

function

 

PopulateSalesGrid(results) {

 

 

 

 

 

var rgGrid  = $find("<%= RadGrid1.ClientID %>").get_masterTableView();

 

rgGrid.set_dataSource(results); // here i get error value cannot be null

rgGrid.dataBind();

 

 

}

** I would perfer not to have the grid populated on page load.

I also tried binding the radgrid on page load (code behind) and hiding it before button clicking event .... and showing if after the click event. But the issue here is ... when you cllick on the 'checked All' checkbox it gets all the values from the previous (page load) databind and not the values from the PopulateSalesGrid function.

Any ideas how to fix this?

thanks!!

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Oct 2011, 06:42 AM
Hello Diane,

Make sure that you have specified the web service method appropriately. Check the following help documentation which explains more about this.
Client-side Binding.

Thanks,
Shinu.
0
Anders
Top achievements
Rank 1
answered on 11 Oct 2017, 01:16 PM
This question seems unreadable to me.
Tags
Grid
Asked by
diane
Top achievements
Rank 1
Veteran
Answers by
Shinu
Top achievements
Rank 2
Anders
Top achievements
Rank 1
Share this question
or