clientside databinding

2 posts, 0 answers
  1. Ingo Oltmann
    Ingo Oltmann avatar
    44 posts
    Member since:
    Nov 2005

    Posted 16 Feb 2012 Link to this post

    Hi,

    I am facing the following issue. When I use this approach to bind data on clientside, the datalist is rendered on pageload:

    <telerik:RadListView ID="ListViewCarImages" runat="server" AllowPaging="false" PageSize="999">
      <LayoutTemplate>
        <div id="listView">
          <div id="items">
          </div>
        </div>
      </LayoutTemplate>
      <ClientSettings>
        <ClientEvents />  
        <DataBinding ItemPlaceHolderID="items">
          <ItemTemplate>
    ...
          </ItemTemplate>
          <SelectedItemTemplate>
    ...
              </SelectedItemTemplate>
              <EmptyDataTemplate>
               ...
          </EmptyDataTemplate>
              <DataService Location="~/AluWebService.asmx" DataPath="CarsImagesList" />
            </DataBinding>
      </ClientSettings>
        </telerik:RadListView>


    but when I choose this approach, no data is rendered at all though the data is sent over the wire as seen using httpfox:


                <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                    <Scripts>
    .....
                    </Scripts>
                    <Services>             
                    <asp:ServiceReference Path="~/AluWebService.asmx" /> 
                    </Services>
                </telerik:RadScriptManager>

    and

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      <script type="text/javascript">
          function pageLoad() {
              listView = $find("<%= ListViewCarImages.ClientID %>");
              var xyz = AluWebService.CarsImagesList();
              listView.set_dataSource(xyz);
              listView.dataBind();
          }
    </script>
    </telerik:RadCodeBlock>

    any idea why the second approach does not work?

    Regards,
    Ingo

  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 21 Feb 2012 Link to this post

    Hi Ingo,

    The second approach does not work, because web service calls asynchronous. The AluWebService.CarsImagesList() method does not return the data synchronously. Instead, it accepts a success callback that will be called one the data is retrieved:

    function pageLoad() {
        listView = $find("<%= ListViewCarImages.ClientID %>");
        AluWebService.CarsImagesList(function(result) {
            listView.set_dataSource(result);
            listView.dataBind();
        });
    }

    Veli
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top