ListView data not rebound after navigation to another partial view

6 posts, 1 answers
  1. Shabtai
    Shabtai avatar
    38 posts
    Member since:
    Nov 2012

    Posted 01 Jan 2013 Link to this post

    Hello,
    First time data is bound okay via controller.

        @(Html.Kendo().ListView<Models.InterfaceModel>(Model)
                    .Name("listView").Events(ev => ev.Change("onSelected"))
            .TagName("div")
            .ClientTemplateId("list-view-template")
            .DataSource(dataSource => dataSource
                        .Model(model => model.Id("InterfaceId"))
                .PageSize(6)
                .Read(read => read.Action("ReadInterfaceListView", "Home"))
            )
            .Pageable()    
            .Selectable()
        )

    after I navigate to another partial view and return to the partial view with above kendo listview, data is not bound (though it IS sent from controller okay - I see it in debug Model is filled okay)

    Any help would be appreciated.

    Thanks
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 02 Jan 2013 Link to this post

    Hello Shabtai,

    It is not getting clear what exactly is the issue you experience. Please elaborate by providing more details (and code snippets) how exactly you load that ListView the 'first' time and 'later' when you load it into a partial view.


    Kind regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Shabtai
    Shabtai avatar
    38 posts
    Member since:
    Nov 2012

    Posted 02 Jan 2013 Link to this post

    I'm using Kendo menu
        
    <div  >
        @(Html.Kendo().Menu()
            .Name("Menu").Events(ev=>ev.Select("onSelected"))
            .Items(items =>
            {
                items.Add()
                    .Text("Create")
                    .Items(children =>
                    {
                        children.Add().Text("Create Interface").HtmlAttributes(new { @idname = "/Home/CreateInterfaceWZ" });
                        
          items.Add()
                    .Text("Run")
                    .Items(children =>
                    {
                        children.Add().Text("Run Interface").HtmlAttributes(new { @idname = "/Home/ChooseInterfaceWZ" });
     
     
            })
        )
    </div>

    in JS I catch onSelected:

    function onSelected(e) {
            var idname = $(e.item).attr('idname');
            if (idname == undefined) return false;
            var address = idname;

        // Call the controller action
        $.ajax({
            type: 'GET',
            url: address,
            success: function (response) {
                // Update the content div
                $('#content').html(response);
            },
            error: function (request, status, errorThrown) {
                alert("error");
                debugger;
            }
        });
     
    }
    where I call partial view in 'address'

    When navigating to menu item and clicking it, the 1st partial view (CreateInterfaceWZ)
    works ok, but when I call after that, ChooseInterfaceWZ partial view from 2nd menu item, it contains following
    @model List<Models.InterfaceModel>
                
    <div >
     
        <div class="k-toolbar k-grid-toolbar">
            <h1 style="color:#4B6C9E;display: inline;">List
            </h1>
        </div>
     
        <script id="list-view-template" type="text/x-kendo-template">
            <div class="product-view">
                    <dl>
                        <dd style='visibility:hidden'>${InterfaceId}</dd>
                        <dd>${InterfaceName}</dd>
                        <dd style='visibility:hidden'>${ViewName}</dd>
                    </dl>
            </div>
        </script>
     
        @(Html.Kendo().ListView<Models.InterfaceModel>(Model)
                            .Name("listView").Events(ev => ev.Change("onSelected"))
            .TagName("div")
            .ClientTemplateId("list-view-template")
            .DataSource(dataSource => dataSource
                        .Model(model => model.Id("InterfaceId"))
                .PageSize(6)
                .Read(read => read.Action("ReadInterfaceListView", "Home"))
            )
            .Pageable()   
            .Selectable()
        )
        <input type="hidden" id="aType" value="@ViewData["ActionType"]" />
    </div>

    The ListView is not populated...

    Here is my controller action:

    public ActionResult ReadInterfaceListView([DataSourceRequest] DataSourceRequest request)
    {
        var ifs = InterfaceDBManager.GetInterfaceListWithModel();
     
        return Json(ifs.ToDataSourceResult(request));
     
    }

    Thank you for your time.
  5. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 02 Jan 2013 Link to this post

    Hello Shabtai,

    Are there any JavaScript errors in the console? Also are you sure that you have added the needed script into the page in which you load the ListView?

    Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Shabtai
    Shabtai avatar
    38 posts
    Member since:
    Nov 2012

    Posted 02 Jan 2013 Link to this post

    The problem is that when I navigate straight to the partial view containing Listview - I do get data okay.
    Only when I start navigation from another item and then go to the listview it's not populated...
  7. Shabtai
    Shabtai avatar
    38 posts
    Member since:
    Nov 2012

    Posted 02 Jan 2013 Link to this post

    It started working like a charm after I added following scripts
    1. kendo.core.js
    2. kendo.data.js
    3. kendo.selectable.js (if selection is enabled)
    4. kendo.listview.js
    Wierd, how it did fill data for the first entry without above scripts...

    Even more, the 'onSelected' event started to work properly . Before that it fired only occasionally.
    Thank you again!
Back to Top
Kendo UI is VS 2017 Ready