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

ListView.dataSource (IE8,9)

4 Answers 106 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 29 May 2013, 06:11 PM
Hi My code below works fine in IE 10 , however it doesn't appear to work on page load event when using IE 8 or IE9. In brief I have a ListView that I bind manually upon page load and everytime something changes in the AutoComplete control. In IE9 and 8 the only thing that's's not working is being able to populating the ListView upon page load. I'm attempting to read the datasource of ListView to populate it. Look at my comment below in the Java Script section. As soon as I type something  in the AutoComplete text. then the listview populates and everything else works just fine. Maybe the sequence of where I have the .read() command should be moved to somewhere else to be able to refresh the ListView. But I'm not sure where. Any Ideas?

@model IEnumerable<HeatSeekerWeb.Models.Document>

<script type="text/x-kendo-tmpl" id="template">
    <div class="Document" id="template">
        <h3>#:Title#</h3>
        <a href="@Url.Content("~/Document/Download?url=#:Path#&fileName=#:FileName#")"><small>#:FileName#</small></a>        
        <p>#:Description#</p>
        <hr />
    </div>
</script>
<div id="divSearchDoc">
            @(Html.Kendo().AutoComplete()
        .Name("acDocuments")
        .Filter("startswith")
        .HtmlAttributes(new { style = "width:500px" })
        .Placeholder("Search Title...")
        .DataTextField("Title")
        .DataSource(source =>
                    {
                        source.Read(
                            read =>
                            {
                                read.Action("Get_Documents", "Document")
                                    .Data("onAdditionalData");
                            }
                            )
                            .ServerFiltering(true);
                    })
        .Events(events => events.DataBound("onDataBound").Select("onSelect").Change("onChange"))
        )
        @Html.ActionLink("Upload Document", "Create", "Document")
</div>
<div class="documents-sections">
    @(Html.Kendo().ListView<HeatSeekerWeb.Models.Document>()
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("template")
    .DataSource(dataSource =>
    {
        dataSource.Read(read => read.Action("Documents_Read", "Document").Data("getSelectedItems"));
        dataSource.PageSize(4);
    })
    .AutoBind(false)
    .Pageable()
)
</div>
<script>
    $(function () {
        // THIS LINE DOESN'T WORK on IE 8 and IE 9. No Problem in IE10
        $("#listView").data("kendoListView").dataSource.read();
    });

    function onAdditionalData() {
        return {
            text: $("#acDocuments").val()
        };
    }

    function getSelectedItems(e) {
        return { text: $("#acDocuments").val() };
    }

    function onDataBound(e) {
        $("#listView").data("kendoListView").dataSource.read();
    };
    function onChange() {
        $("#listView").data("kendoListView").dataSource.read();
    }

    function onSelect(e) {
        //var dataItem = this.dataItem(e.item.index());
        $("#listView").data("kendoListView").dataSource.read();
    }

</script>

4 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 30 May 2013, 07:12 AM
Hello Aaron,

The page setup looks correct to me. The code for DataSource read is executed inside jQuery.ready handler so at the point it gets executed the other Kendo UI widgets should initialized already.

Do you see any JavaScript errors in the browser console when this happens? Could wrap a runnable sample that replicates the behavior?

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Aaron
Top achievements
Rank 1
answered on 30 May 2013, 07:17 PM
Hi Thanks for reply. I realized that the AutoComplete's Placeholder text was causing trouble. In IE10 the Value of the text is returned Empty, but in IE8 and IE9 the Value of AutoComplete returns the PlaceHolder's Text by default, which was causing empty result in the Linq query. 


0
Nikolay Rusev
Telerik team
answered on 31 May 2013, 06:33 AM
Hello Aaron,

We are considering this as resolved, right?

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Aaron
Top achievements
Rank 1
answered on 31 May 2013, 06:58 PM
Yes! Thank you
Tags
ListView
Asked by
Aaron
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Aaron
Top achievements
Rank 1
Share this question
or