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

ListView data not rebound after navigation to another partial view

5 Answers 123 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Shabtai
Top achievements
Rank 1
Shabtai asked on 01 Jan 2013, 11:38 AM
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

5 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 02 Jan 2013, 09:02 AM
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!
0
Shabtai
Top achievements
Rank 1
answered on 02 Jan 2013, 09:54 AM
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.
0
Accepted
Petur Subev
Telerik team
answered on 02 Jan 2013, 10:59 AM
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!
0
Shabtai
Top achievements
Rank 1
answered on 02 Jan 2013, 11:03 AM
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...
0
Shabtai
Top achievements
Rank 1
answered on 02 Jan 2013, 11:36 AM
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!
Tags
ListView
Asked by
Shabtai
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Shabtai
Top achievements
Rank 1
Share this question
or