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

Accessing Data From Client Side

3 Answers 139 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mohamed Salah Al-Din
Top achievements
Rank 1
Mohamed Salah Al-Din asked on 27 Jan 2010, 09:16 AM
Dear Sir,
This Example is the same you have in the online documentation, but it's not working.
please i need this functionality to be able to access the data from the client side.

<telerik:RadListView ID="RadListView1" runat="server" ClientDataKeyNames="ID">  
</telerik:RadListView> 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
<script type="text/javascript">  
function GetClientDataKeyValueForFirstItem()   
{  
   var clientDataKeyValues = $find("<%= RadListView1.ClientID %>").get_clientDataKeyValue();  
   var firstItemKeyValue = clientDataKeyValues[0]["ID"];  
}  
</script> 
</telerik:RadCodeBlock>  

note: my telerik version is (2009.3.1016.35)
Regards,

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 27 Jan 2010, 09:31 AM
Mohamed,

You should first databind the control before you can access the clientDataKeyValue values.

Regards,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mohamed Salah Al-Din
Top achievements
Rank 1
answered on 27 Jan 2010, 10:12 AM
Dear Rosen,
    Please Review this code.
the first example is sent to you was from the telerik online documentation.

<form id="form1" runat="server">  
    <telerik:RadScriptManager runat="server" ID="RSM_Demo" /> 
    <telerik:RadCodeBlock ID="RCB_Demo" runat="server">  
 
        <script type="text/javascript">  
        function OnClientButtonClicked(sender, args)  
          {  
            var button = args.get_item();  
            alert('Button Text:' + button.get_text());  
            alert('Button Command Name:' + button.get_commandName());  
            alert('Button Command Argument:' + button.get_commandArgument());  
            alert('Button Value:' + button.get_value());  
//            var index = button.get_index();  
//            alert('List Index:' + index);  
            var clientDataKeyValues = $find('<%=((RadListView)RPB_Address.Items[0].Items[0].FindControl("RLV_Address")).ClientID%>').get_clientDataKeyValue();              
            //get index 0 value  
            var id = clientDataKeyValues[0]["CustomerID"];  
            alert('Target ID:' + id);  
          }  
          </script> 
    </telerik:RadCodeBlock>            
    <div style="width:100%">  
        <table dir="rtl" cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid #CACACA;">  
            <tr> 
                <td id="AddressZone">  
                    <asp:SqlDataSource runat="server" ID="SDS_Addresses" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
                        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [CustomerID],[CompanyName],[ContactName],[Address],[City],[Region],[PostalCode] FROM [Northwind].[dbo].[Customers]" /> 
                    <telerik:RadPanelBar dir="rtl" ID="RPB_Address" runat="server" Height="241px" Width="100%" 
                        ExpandMode="FullExpandedItem" Style="float: left" Skin="Vista">  
                        <Items> 
                            <telerik:RadPanelItem Text="Addresses" Expanded="true" ImageUrl="Images/map.png" 
                                ImagePosition="Right">  
                                <Items> 
                                    <telerik:RadPanelItem> 
                                        <ItemTemplate> 
                                            <telerik:RadListView ID="RLV_Address" runat="server" DataKeyNames="CustomerID" ClientDataKeyNames="CustomerID" 
                                                DataSourceID="SDS_Addresses" ItemPlaceholderID="PlaceHolder1" Skin="Vista">  
                                                <LayoutTemplate> 
                                                    <asp:Panel ID="pnl_Address" runat="server" Width="100%" Height="181px" ScrollBars="Vertical" 
                                                        HorizontalAlign="Center">  
                                                        <table dir="rtl" cellpadding="5" cellspacing="5" width="95%" style="text-align: right;">  
                                                            <tr> 
                                                                <td> 
                                                                    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> 
                                                                </td> 
                                                            </tr> 
                                                        </table> 
                                                    </asp:Panel> 
                                                    <telerik:RadToolBar ID="RTB_Address" runat="server" Width="100%" Skin="Office2007" 
                                                        dir="rtl">  
                                                        <Items> 
                                                            <telerik:RadToolBarButton ImageUrl="Images\map_add.png" CommandName="Add">  
                                                            </telerik:RadToolBarButton> 
                                                        </Items> 
                                                    </telerik:RadToolBar> 
                                                </LayoutTemplate> 
                                                <ItemTemplate> 
                                                    <table cellpadding="5" cellspacing="5" style="width: 100%; border: 1px solid #CACACA;  
                                                        padding: 5;" dir="rtl">  
                                                        <tr> 
                                                            <td colspan="2">  
                                                                <telerik:RadToolBar ID="RTB_Address_In" Orientation="Horizontal" runat="server" Width="100%" 
                                                                    Skin="Office2007" dir="rtl" OnClientButtonClicked="OnClientButtonClicked">  
                                                                    <Items> 
                                                                        <telerik:RadToolBarButton Text="Edit" Width="50px" ImageUrl="Images\map_edit.png" CommandName="Edit" PostBack="false" 
                                                                            ImagePosition="AboveText" CommandArgument='<%#Eval("CustomerID") %>' Value='<%#Eval("CustomerID") %>'>  
                                                                        </telerik:RadToolBarButton> 
                                                                        <telerik:RadToolBarButton Text="Delete" Width="50px" ImageUrl="Images\map_delete.png" CommandName="Delete" PostBack="false" 
                                                                            ImagePosition="AboveText" CommandArgument='<%#Eval("CustomerID") %>' Value='<%#Eval("CustomerID") %>'>  
                                                                        </telerik:RadToolBarButton> 
                                                                    </Items> 
                                                                </telerik:RadToolBar> 
                                                            </td> 
                                                        </tr> 
                                                        <tr> 
                                                            <td nowrap="nowrap">  
                                                                <asp:Label ID="lbl_City" runat="server" Text="المدينة :"></asp:Label> 
                                                            </td> 
                                                            <td nowrap="nowrap">  
                                                                <%#Eval("CompanyName")%> 
                                                            </td> 
                                                        </tr> 
                                                        <tr> 
                                                            <td nowrap="nowrap">  
                                                                <asp:Label ID="lbl_Address_1" runat="server" Text="العنوان 1 :"></asp:Label> 
                                                            </td> 
                                                            <td nowrap="nowrap">  
                                                                <%#Eval("Address")%> 
                                                            </td> 
                                                        </tr> 
                                                        <tr> 
                                                            <td nowrap="nowrap">  
                                                                <asp:Label ID="lbl_Address_2" runat="server" Text="العنوان 2 :"></asp:Label> 
                                                            </td> 
                                                            <td nowrap="nowrap">  
                                                                <%#Eval("PostalCode")%> 
                                                            </td> 
                                                        </tr> 
                                                    </table> 
                                                    <div> 
                                                    </div> 
                                                </ItemTemplate> 
                                            </telerik:RadListView> 
                                        </ItemTemplate> 
                                    </telerik:RadPanelItem> 
                                </Items> 
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelBar> 
                </td> 
            </tr> 
        </table> 
    </div> 
    </form> 

please browse it and try to response me back.

Regards,
0
Rosen
Telerik team
answered on 27 Jan 2010, 11:01 AM
Mohamed,

The RadListView's clientDataKeyValue is not implemented in the Beta version of Q3 2009 of RadControls for ASP.NET AJAX, which you are using. Thus please upgrade to a later version of the control.

Greetings,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ListView
Asked by
Mohamed Salah Al-Din
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Mohamed Salah Al-Din
Top achievements
Rank 1
Share this question
or