Kendo Base

scripts for kendo ui

by baltatescualin

HTML

<script src="http://cdn.kendostatic.com/2012.1.229/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.229/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.229/styles/kendo.default.min.css">
<div id="example" class="k-content">
            <div id="grid"></div>
</div>
<script id="popup_editor" type="text/x-kendo-template">
    <p> My Custom template</p>
    <select data-bind="source: collection"></select>
</script>

JavaScript

var people = [
    {
    FirstName: "Ted",
    LastName: "Bal",
    City: "LA",
    Title: "Title",
    BirthDate: "25-09-2012",
    Age: "21",
    collection: [
        {id: "1",name: "Picture 1"},
        {id: "2",name: "Picture 2"},
        {id: "3",name: "Picture 3"}
    ]}
];

$("#grid").kendoGrid({
    dataSource: {
        data: people,
        schema: {
            model: {
                fields: {
                    FirstName: {
                        type: "string"
                    },
                    LastName: {
                        type: "string"
                    },
                    City: {
                        type: "string"
                    },
                    Title: {
                        type: "string"
                    },

                    BirthDate: {
                        type: "string"
                    },
                    Age: {
                        type: "number"
                    },
                    collection: {
                        type: "string"
                    }
                }
            }
        },
        pageSize: 10
    },
    height: 250,
    scrollable: true,
    sortable: true,
    filterable: true,
    editable: {
        mode: "popup",
        template: $("#popup_editor").html()
    },
    pageable: {
        input: true,
        numeric: false
    },
    columns: [
        {
        field: "FirstName",
        title: "First Name",
        width: 100},
    {
        field: "LastName",
        title: "Last Name",
        width: 100},
    {
        field: "City",
        width: 100},
    {
        field: "Title"},

    {
        field: "BirthDate",
        title: "Birth Date",
        template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'},
    {
        field: "Age",
        width: 50},
    {
        field: "collection"},
    {
        command: ['edit', 'destroy'],
        title: '&nbsp;',
        width: '210px'}
    ]
});