$update = new \Kendo\Data\DataSourceTransportUpdate(); $update->url('/api/products/update.php')->contentType('application/json')->type('PUT'); $destroy = new \Kendo\Data\DataSourceTransportDestroy(); $destroy->url('/api/products/destroy.php')->contentType('application/json')->type('POST'); $transport = new \Kendo\Data\DataSourceTransport(); $transport->create($create)->read($read)->update($update)->destroy($destroy)->parameterMap('function(data) { return kendo.stringify(data); }'); // --------- Kendo UI DataSource Schema ------- $model = new \Kendo\Data\DataSourceSchemaModel(); $productNameField = new \Kendo\Data\DataSourceSchemaModelField('ProductName'); $productNameField->type('string'); $unitPriceField = new \Kendo\Data\DataSourceSchemaModelField('UnitPrice'); $unitPriceField->type('number'); $unitsInStockField = new \Kendo\Data\DataSourceSchemaModelField('UnitsInStock'); $unitsInStockField->type('number'); $supplierField = new \Kendo\Data\DataSourceSchemaModelField("Supplier"); $supplierField->defaultValue(new stdClass()); $categoryField = new \Kendo\Data\DataSourceSchemaModelField("Category"); $categoryField->defaultValue(new stdClass()); $model->id("ProductID")->addField($productNameField)->addField($unitPriceField)->addField($unitsInStockField)->addField($supplierField)->addField($categoryField); $schema = new \Kendo\Data\DataSourceSchema(); $schema->data('data')->model($model)->total('total'); // --------- Kendo UI DataSource ------- $dataSource = new \Kendo\Data\DataSource(); $dataSource->transport($transport)->pageSize(5)->schema($schema)->serverPaging(true); // --------- Kendo UI Grid ------- $grid = new \Kendo\UI\Grid('grid'); $productName = new \Kendo\UI\GridColumn(); $productName->field('ProductName')->title('Product Name'); $supplier = new \Kendo\UI\GridColumn(); $supplier->field('Supplier')->title("Supplier")->editor('supplierEditor')->template("#: Supplier.SupplierName #"); $category = new \Kendo\UI\GridColumn();
<?php require_once '../lib/Kendo/Autoload.php'; require_once '../include/header.php'; $data = array(array('meetingID' => 1, 'title' => 'Call Charlie about the project', 'start' => new DateTime('2013/6/13 10:30'), 'end' => new DateTime('2013/6/13 11:30'), 'roomId' => 1, 'attendee' => 1), array('meetingID' => 2, 'title' => 'Performance review', 'start' => new DateTime('2013/6/13 9:00'), 'end' => new DateTime('2013/6/13 12:30'), 'roomId' => 2, 'attendee' => 2), array('meetingID' => 3, 'title' => 'HR Lecture', 'start' => new DateTime('2013/6/13 13:00'), 'end' => new DateTime('2013/6/13 14:30'), 'roomId' => 1, 'attendee' => 2)); $model = new \Kendo\Data\DataSourceSchemaModel(); $startField = new \Kendo\Data\DataSourceSchemaModelField('start'); $startField->type('date'); $endField = new \Kendo\Data\DataSourceSchemaModelField('end'); $endField->type('date'); $titleField = new \Kendo\Data\DataSourceSchemaModelField('title'); $titleField->defaultValue('No title')->validation(array('required' => true)); $roomIdField = new \Kendo\Data\DataSourceSchemaModelField('roomId'); $roomIdField->nullable(true); $attendeeField = new \Kendo\Data\DataSourceSchemaModelField('attendee'); $attendeeField->defaultValue(1); $model->id('meetingID')->addField($roomIdField)->addField($startField)->addField($endField)->addField($attendeeField)->addField($titleField); $schema = new \Kendo\Data\DataSourceSchema(); $schema->model($model); $dataSource = new \Kendo\Data\DataSource(); $dataSource->data($data)->schema($schema); $roomResource = new \Kendo\UI\SchedulerResource(); $roomResource->field('roomId')->title('Room')->name('Rooms')->dataSource(array(array('text' => 'Meeting Room 101', 'value' => 1, 'color' => '#6eb3fa'), array('text' => 'Meeting Room 201', 'value' => 2, 'color' => '#f58a8a'))); $attendeesResource = new \Kendo\UI\SchedulerResource(); $attendeesResource->field('attendee')->title('Attendee')->name('Attendee')->dataSource(array(array('text' => 'Alex', 'value' => 1, 'color' => '#f8a398'), array('text' => 'Bob', 'value' => 2, 'color' => '#51a0ed'))); $scheduler = new \Kendo\UI\Scheduler('scheduler'); $scheduler->date(new DateTime('2013/6/13'))->height(600)->addResource($attendeesResource, $roomResource)->group(array('resources' => array('Rooms')))->addView(array('type' => 'day', 'startTime' => new DateTime('2013/6/13 7:00')))->resize('scheduler_resize')->resizeEnd('scheduler_resizeEnd')->move('scheduler_move')->moveEnd('scheduler_moveEnd')->addEvent('scheduler_add')->save('scheduler_save')->dataSource($dataSource); echo $scheduler->render(); ?> <script>
$destroy = new \Kendo\Data\DataSourceTransportDestroy(); $destroy->url('editing-custom.php?type=destroy')->contentType('application/json')->type('POST'); $transport->create($create)->read($read)->update($update)->destroy($destroy)->parameterMap('function(data) { return kendo.stringify(data); }'); $model = new \Kendo\Data\DataSourceSchemaModel(); $productIDField = new \Kendo\Data\DataSourceSchemaModelField('ProductID'); $productIDField->type('number')->editable(false)->nullable(true); $productNameField = new \Kendo\Data\DataSourceSchemaModelField('ProductName'); $productNameField->type('string')->validation(array('required' => true)); $unitPriceValidation = new \Kendo\Data\DataSourceSchemaModelFieldValidation(); $unitPriceValidation->required(true)->min(1); $unitPriceField = new \Kendo\Data\DataSourceSchemaModelField('UnitPrice'); $unitPriceField->type('number')->validation($unitPriceValidation); $categoryField = new \Kendo\Data\DataSourceSchemaModelField('Category'); $categoryField->defaultValue(array('CategoryID' => 1, 'CategoryName' => 'Beverages')); $model->id('ProductID')->addField($productIDField)->addField($productNameField)->addField($unitPriceField)->addField($categoryField); $schema = new \Kendo\Data\DataSourceSchema(); $schema->data('data')->errors('errors')->model($model)->total('total'); $dataSource = new \Kendo\Data\DataSource(); $dataSource->transport($transport)->batch(true)->pageSize(30)->schema($schema); $grid = new \Kendo\UI\Grid('grid'); $productName = new \Kendo\UI\GridColumn(); $productName->field('ProductName')->title('Product Name'); $unitPrice = new \Kendo\UI\GridColumn(); $unitPrice->field('UnitPrice')->format('{0:c}')->width(150)->title('Unit Price'); $category = new \Kendo\UI\GridColumn(); $category->field('Category')->title('Category')->template('#=Category.CategoryName#')->editor('categoryDropDownEditor')->width(180); $command = new \Kendo\UI\GridColumn(); $command->addCommandItem('destroy')->title(' ')->width(110); $grid->addColumn($productName, $category, $unitPrice, $command)->dataSource($dataSource)->addToolbarItem(new \Kendo\UI\GridToolbarItem('create'), new \Kendo\UI\GridToolbarItem('save'), new \Kendo\UI\GridToolbarItem('cancel'))->height(400)->navigatable(true)->editable(true)->groupable(true)->save('save')->pageable(true);