LiveTiles RadODataDataSource OnClientDataLoading

2 posts, 0 answers
  1. Steven
    Steven avatar
    8 posts
    Member since:
    Mar 2009

    Posted 26 Aug 2015 Link to this post

    I am trying to use the RadLiveTiles to display data from an oDataDataSource. If I create a different data source for each tile and set the OnClientDataLoading to a different function that sets the filter with the correct parameters for each tile everything works fine.

    Since I will have many tiles I found this in your documentation

    "Another option is to change the filter in the OnClientDataLoading event, because the event arguments expose the data source arguments. Essentially, the logic is the same, but you can apply filters per LiveTile (e.g., by using different OnClientDataLoading event handlers, see Example 8) and use the same ODataDataSource control."

     However when I try this it is not working. The first tile works fine, but when the 2nd fires, it first calls the first over again, then the second, and the data returned is from the first. When the 3rd tile fires it again calls the 1st, then the 2nd then the 3rd and the data is the first when first initialized. When the first update interval occurs all tiles refresh at the same time, again with the data all being from the first tile

     This is the code I am using

     <script type="text/javascript">
            function OnClientDataLoading(sender, args) {
                alert("1")
                args.get_value().filter.filters.push({
                    field: "MasterID",
                    operator: "eq",
                    value: 32
                });
            }

            function OnClientDataLoading1(sender, args) {
                alert("2")
                args.get_value().filter.filters.push({
                    field: "MasterID",
                    operator: "eq",
                    value: 64
                });
            }

            function OnClientDataLoading2(sender, args) {
                alert("3")
                args.get_value().filter.filters.push({
                    field: "MasterID",
                    operator: "eq",
                    value: 44
                });
            }

        </script>


        <form id="form1" runat="server">
            <div>

                <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableTheming="True" />
            </div>

            <div>

                <telerik:RadODataDataSource runat="server" ID="RadODataDataSource1">
                    <Transport Read-DataType="JSONP">
                        <Read Url="http://xxxxxx.com/tService1/TileService.svc/" />
                    </Transport>
                    <Schema>
                        <telerik:DataModel ModelID="opItemLiveTileData" Set="opItemLiveTileDatas">
                            <telerik:DataModelField FieldName="MasterID" />
                            <telerik:DataModelField FieldName="nOrders" />
                        </telerik:DataModel>
                    </Schema>
                </telerik:RadODataDataSource>


                <telerik:RadTileList runat="server" ID="RadTileList2" TileRows="4" Width="1300px" SelectionMode="Single" EnableDragAndDrop="false" BackColor="teal" AutoPostBack="false" >
                    <Groups>
                        <telerik:TileGroup>
                            <telerik:RadLiveTile ID="RadLiveTile3" runat="server" ODataDataSourceID="RadODataDataSource1" DataModelID="opItemLiveTileData" UpdateInterval="6000"  OnClientDataLoading="OnClientDataLoading" AutoPostBack="false">
                                <ClientTemplate>
                    <strong>Loaded from ODataDataSource: </strong><br />
                           #= MasterID # <br></br> #= nOrders # <br></br> 
                                </ClientTemplate>
                            </telerik:RadLiveTile>


                            <telerik:RadLiveTile ID="RadLiveTile1" runat="server" ODataDataSourceID="RadODataDataSource1" DataModelID="opItemLiveTileData" UpdateInterval="9000"  OnClientDataLoading="OnClientDataLoading1" AutoPostBack="false">
                                <ClientTemplate>
                    <strong>Loaded from ODataDataSource: </strong><br />
                           #= MasterID # <br></br> #= nOrders # <br></br> 
                                </ClientTemplate>
                            </telerik:RadLiveTile>

                            <telerik:RadLiveTile ID="RadLiveTile2" runat="server" ODataDataSourceID="RadODataDataSource1" DataModelID="opItemLiveTileData" UpdateInterval="11000"  OnClientDataLoading="OnClientDataLoading2" AutoPostBack="false">
                                <ClientTemplate>
                    <strong>Loaded from ODataDataSource: </strong><br />
                           #= MasterID # <br></br> #= nOrders # <br></br> 
                                </ClientTemplate>
                            </telerik:RadLiveTile>
                        </telerik:TileGroup>
                    </Groups>
                </telerik:RadTileList>



                <script type="text/javascript">
                </script>
            </div>
        </form>

    Any help would be greatly appreciated as my only alternative is to create a datasource for each tile.

     

  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 28 Aug 2015 Link to this post

    Hello Steven,

    The implemented approach is expected to behave as described. Also, I would like to mention that the use of the LiveTile controls in this case is not accurate as per to the purpose of the control's design.

    Firstly, several filters are being added to the same ODataDataSource instance. Thus, by adding up filters, the requested data only populates more data. Therefore, at the end, there is always the same data bound to the LiveTile controls respecting all the filters added in the stack.

    The description in the documentation rather refers to filtering the requested data once. And this would work as you would expected if each LiveTile is associated with different ODataDataSource control. By that, each filtered data will be unique as per to the DataSource control used and will re-bind the Tile that is assigned to.

    Also, the approach used in this online demo (http://demos.telerik.com/aspnet-ajax/tilelist/examples/livetiles/defaultcs.aspx) is much more relevant to the case. As you can see, each LiveTile uses one Web Server, where the service is implemented accordingly to filter the data that the tile requests.Essentially, it is responsibility of the service or the DataSource control to filter the data and not of the control that is bound to the data.

    Regards,
    Ianko
    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
Back to Top