Exemplo n.º 1
0
        static void OnReady()
        {
            new jQuery("#treeview").kendoTreeView(new TreeViewConfiguration
            {
                templateFunction = Kendo.template(new jQuery("#treeview-template").html()),

                checkboxTemplateFunc = Kendo.template(new jQuery("#treeview-checkbox-template").html()),

                dataSource = new JsArray {
                    new  { id = 1, text = "My Documents", expanded = true, spriteCssClass = "rootfolder", items = new JsArray {
                               new {
                                   id = 2, text = "Kendo UI Project", expanded = true, spriteCssClass = "folder", items = new JsArray {
                                       new { id = 3, text = "about.html", spriteCssClass = "html" },
                                       new { id = 4, text = "index.html", spriteCssClass = "html" },
                                       new { id = 5, text = "logo.png", spriteCssClass = "image" }
                                   }
                               },
                               new {
                                   id = 6, text = "New Web Site", expanded = true, spriteCssClass = "folder", items = new JsArray {
                                       new { id = 7, text = "mockup.jpg", spriteCssClass = "image" },
                                       new { id = 8, text = "Research.pdf", spriteCssClass = "pdf" },
                                   }
                               },
                               new {
                                   id = 9, text = "Reports", expanded = true, spriteCssClass = "folder", items = new JsArray {
                                       new { id = 10, text = "February.pdf", spriteCssClass = "pdf" },
                                       new { id = 11, text = "March.pdf", spriteCssClass = "pdf" },
                                       new { id = 12, text = "April.pdf", spriteCssClass = "pdf" }
                                   }
                               }
                           } }
                }
            });
            new jQuery("#treeview [type=checkbox]").change(showSerializedData);
        }
Exemplo n.º 2
0
        static void OnReady()
        {
            new jQuery("#pager").kendoPager(new PagerConfiguration {
                dataSource = dataSource
            });

            new jQuery("#listView").kendoListView(new ListViewConfiguration {
                dataSource       = dataSource,
                selectableString = "multiple",
                dataBound        = onDataBound,
                change           = onChange,
                template         = Kendo.template(new jQuery("#template").html())
            });
        }
Exemplo n.º 3
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();
        }
        public ActionResult Read(int take, int skip, IEnumerable<Sort> sort, Kendo.DynamicLinq.Filter filter)
        {
            using (var northwind = new Northwind())
            {
                var result = northwind.Products
                    .OrderBy(p => p.ProductID) // EF requires ordered IQueryable in order to do paging
                    // Use a view model to avoid serializing internal Entity Framework properties as JSON
                    .Select(p => new ProductViewModel
                    {
                        ProductID = p.ProductID,
                        ProductName = p.ProductName,
                        UnitPrice = p.UnitPrice,
                        UnitsInStock = p.UnitsInStock,
                        Discontinued = p.Discontinued
                    })
                    .ToDataSourceResult(take, skip, sort, filter);

                return Json(result);
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 static void OnReady()
 {
     new jQuery("#netflixTable").kendoGrid(new GridConfiguration
     {
         dataSourceObject = new DataSourceConfiguration
         {
             type            = "odata",
             serverFiltering = true,
             filter          = new JsArray {
                 new { field = "Name", @operator = "contains", value = "Star Wars" },
                 new { field = "BoxArt.SmallUrl", @operator = "neq", value = "" }
             },
             transport = new DataSourceTransportConfiguration
             {
                 readString = "http://odata.netflix.com/Catalog/Titles"
             }
         },
         rowTemplate = Kendo.template(new jQuery("#rowTemplate").html()),
         height      = 200
     });
 }
Exemplo n.º 7
0
        static void OnReady()
        {
            var grid = new jQuery("#grid").kendoGrid(new GridConfiguration
            {
                dataSourceObject = new DataSourceConfiguration
                {
                    pageSize = 10,
                    data     = People.createRandomData(50)
                },
                pageableBoolean = true,
                height          = 260,
                columns         = new JsArray <GridColumnConfiguration> {
                    new GridColumnConfiguration {
                        field = "FirstName", title = "First Name"
                    },
                    new GridColumnConfiguration {
                        field = "LastName", title = "Last Name"
                    },
                    new GridColumnConfiguration {
                        field = "Title"
                    },
                    new GridColumnConfiguration {
                        command = new { text = "Details", click = new JsAction <Event>(showDetails) }.As <GridColumnsCommandOptions>(), title = " ", widthString = "110px"
                    }
                }
            }).data("kendoGrid");

            wnd = new jQuery("#details").kendoWindow(new WindowConfiguration
            {
                title     = "Customer Details",
                modal     = true,
                visible   = false,
                resizable = false,
                width     = "300"
            }).data("kendoWindow").As <Window>();
            detailsTemplate = Kendo.template(new jQuery("#template").html());
        }
Exemplo n.º 8
0
        static void OnReady()
        {
            var dataSource = new DataSource(new DataSourceConfiguration
            {
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        url         = "http://search.twitter.com/search.json",
                        contentType = "application/json; charset=utf-8",
                        type        = TransportType.GET,
                        dataType    = "jsonp",
                        data        = new
                        {
                            q = "#kendoui"
                        }
                    }
                },
                schema = new DataSourceSchemaConfiguration
                {
                    data  = "results",
                    total = "results_per_page"
                }
            });

            new jQuery("#pager").kendoPager(new PagerConfiguration
            {
                dataSource = dataSource
            });

            new jQuery("#listView").kendoListView(new ListViewConfiguration
            {
                dataSource = dataSource,
                template   = Kendo.template(new jQuery("#template").html())
            });
        }
Exemplo n.º 9
0
 static void onChange()
 {
     kendoConsole.log("Change :: " + Kendo.toString([email protected] <Calendar>().value().As <JsNumber>(), "d"));
 }
Exemplo n.º 10
0
 public ActionResult GetStates(Kendo.Mvc.UI.DataSourceRequest request)
 {
     IEnumerable<State> states = CityDataSource.CityDataSource.GetCitys().Where(p => !string.IsNullOrEmpty(p.StateInfo.Name)).Select(p => p.StateInfo);
     return Json(states.ToDataSourceResult(request));
 }
Exemplo n.º 11
0
 //TODO: Error: "title is not defind
 static void OnReady()
 {
     template = Kendo.template(new jQuery("#template").html()).As <JsFunc <JsArray, JsString> >();
     preview();
     new jQuery("#preview").click(preview);
 }
Exemplo n.º 12
0
        static void OnReady()
        {
            var fields = new JsObject <FieldConfig>();

            fields["ProductID"] = new FieldConfig {
                editable = false, nullable = true
            };
            fields["ProductName"] = "ProductName".As <FieldConfig>();
            fields["UnitPrice"]   = new FieldConfig {
                type = "number"
            };
            fields["Discontinued"] = new FieldConfig {
                type = "boolean"
            };
            fields["UnitsInStock"] = new FieldConfig {
                type = "number"
            };
            var crudServiceBaseUrl = "http://demos.kendoui.com/service";
            var dataSource         = new DataSource(new DataSourceConfiguration
            {
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        url      = crudServiceBaseUrl + "/Products/Update",
                        dataType = "jsonp"
                    },
                    update = new DataSourceTransportUpdateConfiguration
                    {
                        url      = crudServiceBaseUrl + "/Products/Update",
                        dataType = "jsonp"
                    },
                    destroy = new DataSourceTransportDestroyConfiguration
                    {
                        url      = crudServiceBaseUrl + "/Products/Destroy",
                        dataType = "jsonp"
                    },
                    create = new DataSourceTransportCreateConfiguration
                    {
                        url  = crudServiceBaseUrl + "/Products/Create",
                        data = "jsonp"
                    },

                    parameterMap = (options, operation) =>
                    {
                        if (operation.ExactNotEquals("read") && options.As <JsObject>()["models"].As <bool>())
                        {
                            //TODO: return {models: kendo.stringify(options.models)};
                            JsContext.JsCode("return {models: kendo.stringify(options.models)};");
                            return(null);
                        }
                        return(null);
                    }
                },
                batch    = true,
                pageSize = 4,
                schema   = new DataSourceSchemaConfiguration
                {
                    model = new ModelObjectOptions
                    {
                        id     = "ProductID",
                        fields = fields
                    }
                }
            });

            new jQuery("#pager").kendoPager(new PagerConfiguration
            {
                dataSource = dataSource
            });
            var listView = new jQuery("#listView").kendoListView(new ListViewConfiguration
            {
                dataSource   = dataSource,
                template     = Kendo.template(new jQuery("#template").html()),
                editTemplate = Kendo.template(new jQuery("#editTemplate").html()),
            }).data("kendoListView").As <ListView>();

            new jQuery(".k-add-button").click(e =>
            {
                listView.add();
                e.preventDefault();
            });
        }
Exemplo n.º 13
0
 static void onChange()
 {
     kendoConsole.log("Change :: " + Kendo.toString([email protected] <DateTimePicker>().value().As <JsNumber>(), "g"));
 }
Exemplo n.º 14
0
        static void OnReady()
        {
            // TreeView bound to Categories > Products > OrderDetails
            var OrderDetails = new DataSourceConfiguration
            {
                type      = "odata",
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        urlFunc = options => Kendo.format("http://demos.kendoui.com/service/Northwind.svc/Products({0})/Order_Details", options.As <JsObject>()["ProductID"].As <JsNumber>())
                    }
                },
                schema = new HierarchicalDataSourceSchemaConfiguration
                {
                    model = new HierarchicalDataSourceSchemaModelConfiguration
                    {
                        hasChildrenFunc = () => false
                    }
                }
            };

            var Products = new HierarchicalDataSourceConfiguration
            {
                type   = "odata",
                schema = new HierarchicalDataSourceSchemaConfiguration
                {
                    model = new HierarchicalDataSourceSchemaModelConfiguration
                    {
                        id = "ProductID",
                        hasChildrenString = "Order_Details",
                        children          = OrderDetails
                    }
                },
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        urlFunc = options => Kendo.format("http://demos.kendoui.com/service/Northwind.svc/Categories({0})/Products", options.As <JsObject>()["CategoryID"].As <JsNumber>())
                    }
                }
            };

            var Categories = new HierarchicalDataSource(new HierarchicalDataSourceConfiguration
            {
                type      = "odata",
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        url = "http://demos.kendoui.com/service/Northwind.svc/Categories"
                    }
                },
                schema = new HierarchicalDataSourceSchemaConfiguration
                {
                    model = new HierarchicalDataSourceSchemaModelConfiguration
                    {
                        hasChildrenString = "Products",
                        id       = "CategoryID",
                        children = Products
                    }
                }
            });

            new jQuery("#treeview").kendoTreeView(new TreeViewConfiguration
            {
                dataSource    = Categories.As <JsArray>(),
                dataTextField = new JsArray <JsString> {
                    "CategoryName", "ProductName", "OrderID"
                }.As <JsString>()
            });
        }