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

3 posts, 0 answers
  1. Sampa
    Sampa avatar
    2 posts
    Member since:
    May 2015

    Posted 18 May 2015 Link to this post

    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. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 21 May 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sampa
    Sampa avatar
    2 posts
    Member since:
    May 2015

    Posted 22 May 2015 in reply to Angel Petrov Link to this post

    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. 

Back to Top