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

clientside databinding

1 Answer 59 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ingo Oltmann
Top achievements
Rank 1
Ingo Oltmann asked on 16 Feb 2012, 10:18 PM
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

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Feb 2012, 10:51 AM
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 >>
Tags
ListView
Asked by
Ingo Oltmann
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or