ListView.dataSource (IE8,9)

5 posts, 1 answers
  1. Aaron
    Aaron avatar
    14 posts
    Member since:
    Jan 2012

    Posted 29 May 2013 Link to this post

    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>
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 30 May 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Aaron
    Aaron avatar
    14 posts
    Member since:
    Jan 2012

    Posted 30 May 2013 Link to this post

    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. 


  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 31 May 2013 Link to this post

    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!
  6. Aaron
    Aaron avatar
    14 posts
    Member since:
    Jan 2012

    Posted 31 May 2013 Link to this post

    Yes! Thank you
Back to Top
UI for ASP.NET MVC is VS 2017 Ready