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

Telerik grid does not show records after binding to a list object via clientside.

2 Answers 264 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Sampa
Top achievements
Rank 1
Sampa asked on 18 May 2015, 12:45 PM

I have a telerik grid. I have taken an item template column , in which a label control is taken. I don't use Eval to bind data to a column. I have set the label Id with Datafield property. I want to bind the grid via client side databinding using web method. first I am returning a serialized json string , then I Deserialized this json string in a javascript,  which is converted to a list object. then I pass this list object using set_dataSource(listobject). My requirement is that I have a search button. By clicking it , it will fire an OnClientClick event and binds the grid. My problem is that my grid is binding but no data is showing in label control of that grid. I mean to say, suppose i have four records. After clicking search button grid shows four rows but no data will be shown.

 

My grid is looking like that

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="false" AutoGenerateColumns="true" Skin="Web20" AllowSorting="false" Visible="true" >
                        <HeaderStyle BackColor="#3ABD59" Font-Bold="True" Wrap="False" />
                        
                       <mastertableview cellspacing="-1" AllowMultiColumnSorting="true" DataKeyNames="CustomerId" ClientDataKeyNames="CustomerId">
                           
                            <Columns>

 <telerik:GridTemplateColumn HeaderText="Customer ID" UniqueName="UniCustomerId" >
                                    <ItemTemplate>
                                         <asp:Label runat="server" ID="CustomerId" Style="width:150px;" ></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>

</Columns>
                        </mastertableview>
                        
                        <PagerStyle AlwaysVisible="True"  />
                        
                    </telerik:RadGrid>

 

I have tried with databound column like below

 

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="false" AutoGenerateColumns="true" Skin="Web20" AllowSorting="false" Visible="true" >
                        <HeaderStyle BackColor="#3ABD59" Font-Bold="True" Wrap="False" />
                        
                       <mastertableview cellspacing="-1" AllowMultiColumnSorting="true" DataKeyNames="CustomerId" ClientDataKeyNames="CustomerId">
                           
                            <Columns> 

<telerik:GridBoundColumn DataField="CustomerId" HeaderText="Customer ID" UniqueName="UniCustomerId" DataType="System.String" >
                                </telerik:GridBoundColumn>

</Columns>
                        </mastertableview>
                        
                        <PagerStyle AlwaysVisible="True"  />
                        
                    </telerik:RadGrid>

but results are same.

 

I am stuck with this problem. Any help would be a great favor for me. 

2 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 21 May 2015, 08:41 AM
Hello Sampa,

After examining the matter I have to say that the described behavior is expected. The RadGrid control can not automatically populate the label. In order to achieve this you should subscribe to the OnRowDataBound event, obtain a reference to the HTML element rendered by the label and set its value. An example of such an approach can be seen in this demo.  Have in mind that the demo logic uses findControl whereas you should use findElement which returns the matching HTML element.

Regards,
Angel Petrov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sampa
Top achievements
Rank 1
answered on 22 May 2015, 06:07 AM

hey Angel Petrov,

Thanks for your post. After checking it, I will inform you whether it is working or not. Actually I have achieved my requirement by removing the item template or bound columns. Simply I have taken a grid with no columns  in it. In pageload event I have bind this grid with dummy data. After passing list object grid is binding to the data and shows the desired result. To get the index of a row I am using javascript. And by using javascript I have also able to change it's header text. 

Tags
Documentation and Tutorials
Asked by
Sampa
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Sampa
Top achievements
Rank 1
Share this question
or