Ejemplo n.º 1
0
        static void OnReady()
        {
            // create a template using the above definition
            var template = Kendo.template(new jQuery("#template").html());
            var movies   = new JsArray <Movie> {
                new Movie {
                    rank = 1, rating = 9.2, year = 1994, title = "The Shawshank Redemption"
                },
                new Movie {
                    rank = 2, rating = 9.2, year = 1972, title = "The Godfather"
                },
                new Movie {
                    rank = 3, rating = 9, year = 1974, title = "The Godfather = Part II"
                },
                new Movie {
                    rank = 4, rating = 8.9, year = 1966, title = "Il buono, il brutto, il cattivo."
                },
                new Movie {
                    rank = 5, rating = 8.9, year = 1994, title = "Pulp Fiction"
                },
                new Movie {
                    rank = 6, rating = 8.9, year = 1957, title = "12 Angry Men"
                },
                new Movie {
                    rank = 7, rating = 8.9, year = 1993, title = "Schindler's List"
                },
                new Movie {
                    rank = 8, rating = 8.8, year = 1975, title = "One Flew Over the Cuckoo's Nest"
                },
                new Movie {
                    rank = 9, rating = 8.8, year = 2010, title = "Inception"
                },
                new Movie {
                    rank = 10, rating = 8.8, year = 2008, title = "The Dark Knight"
                }
            };
            var dataSource = new DataSource(new DataSourceConfiguration
            {
                data   = movies,
                change = () => new jQuery("#movies tbody").html(Kendo.render(template, [email protected] <DataSource>().view()))
            });

            dataSource.read();
        }
Ejemplo n.º 2
0
        static void OnReady()
        {
            // create a template using the above definition
            var template   = Kendo.template(new jQuery("#template").html());
            var dataSource = new DataSource(new DataSourceConfiguration
            {
                pageSize = 10,
                data     = People.createRandomData(500),
                // subscribe to the CHANGE event of the data source
                change = () =>
                {
                    // update the max attribute of the "page" input
                    new jQuery("#page").attr("max", [email protected] <DataSource>().totalPages());
                    new jQuery("#people tbody").html(Kendo.render(template, [email protected] <DataSource>().view()));
                }
            });

            // read the data
            dataSource.read();
            new jQuery("#apply").click(() =>
            {
                var page = JsContext.parseInt(new jQuery("#page").val().As <JsString>());   // ,10)
                // validate the page - it must be a number within the allowed range
                if (JsContext.isNaN(page) || page < 1 || page > dataSource.totalPages())
                {
                    HtmlContext.window.alert(Kendo.format("Page must be a number between 1 and {0}", dataSource.totalPages()));
                    return;
                }
                //// query the remote service
                dataSource.query(new DataSourceConfiguration
                {
                    page     = page,
                    pageSize = 10,
                    //TODO: sortOPtions
                    sort = new { field = new jQuery("#order").val(), dir = new jQuery("#dir").val() }
                });
            });
            //initialize dropdownlist components
            new jQuery("#order").kendoDropDownList();
            new jQuery("#dir").kendoDropDownList();
        }