$request = json_decode(file_get_contents('php://input')); $result = new DataSourceResult('sqlite:..//sample.db'); echo json_encode($result->read('Products', array('ProductName', 'UnitPrice', 'UnitsInStock'), $request)); exit; } require_once '../include/header.php'; $transport = new \Kendo\Data\DataSourceTransport(); $read = new \Kendo\Data\DataSourceTransportRead(); $read->url('api.php')->contentType('application/json')->type('POST'); $transport->read($read)->parameterMap('function(data) { return kendo.stringify(data); }'); $schema = new \Kendo\Data\DataSourceSchema(); $schema->data('data')->groups('groups')->total('total'); $dataSource = new \Kendo\Data\DataSource(); $group = new \Kendo\Data\DataSourceGroupItem(); $group->field('UnitsInStock'); $dataSource->transport($transport)->pageSize(5)->addGroupItem($group)->schema($schema)->serverSorting(true)->serverGrouping(true)->serverPaging(true); $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}')->title('Unit Price'); $unitsInStock = new \Kendo\UI\GridColumn(); $unitsInStock->field('UnitsInStock')->title('Units In Stock'); $grid->addColumn($productName, $unitPrice, $unitsInStock)->attr('style', 'width:700px')->selectable('row multiple')->pageable(true)->sortable(true)->groupable(true)->dataSource($dataSource); ?> <div class="configuration k-widget k-header" style="width:190px"> <span class="configHead">API Functions</span> <ul class="options">
$request = json_decode(file_get_contents('php://input')); $result = new DataSourceResult('sqlite:..//sample.db'); echo json_encode($result->read('Employees', array('FirstName', 'LastName', 'City', 'Address', 'HomePhone'), $request)); exit; } require_once '../include/header.php'; $transport = new \Kendo\Data\DataSourceTransport(); $read = new \Kendo\Data\DataSourceTransportRead(); $read->url('navigation.php')->contentType('application/json')->type('POST'); $transport->read($read)->parameterMap('function(data) { return kendo.stringify(data); }'); $schema = new \Kendo\Data\DataSourceSchema(); $schema->data('data')->groups('groups')->total('total'); $dataSource = new \Kendo\Data\DataSource(); $group = new \Kendo\Data\DataSourceGroupItem(); $group->field('City'); $dataSource->transport($transport)->pageSize(5)->addGroupItem($group)->schema($schema)->serverSorting(true)->serverFiltering(true)->serverGrouping(true)->serverPaging(true); $grid = new \Kendo\UI\Grid('grid'); $firstName = new \Kendo\UI\GridColumn(); $firstName->field("FirstName")->title('First Name'); $lastName = new \Kendo\UI\GridColumn(); $lastName->field("LastName")->title('Last Name'); $city = new \Kendo\UI\GridColumn(); $city->field('City'); $address = new \Kendo\UI\GridColumn(); $address->field('Address'); $phone = new \Kendo\UI\GridColumn(); $phone->field('HomePhone'); $grid->addColumn($firstName, $lastName, $city, $address, $phone)->selectable('cell multiple')->pageable(true)->navigatable(true)->sortable(true)->filterable(true)->dataSource($dataSource); echo $grid->render();
$transport->read($read)->parameterMap('function(data) { return kendo.stringify(data); }'); $schema = new \Kendo\Data\DataSourceSchema(); $schema->data('data')->errors('errors')->groups('groups')->aggregates('aggregates')->total('total'); $productNameCount = new \Kendo\Data\DataSourceAggregateItem(); $productNameCount->field("ProductName")->aggregate("count"); $unitsOnOrderAvg = new \Kendo\Data\DataSourceAggregateItem(); $unitsOnOrderAvg->field("UnitsOnOrder")->aggregate("average"); $unitsInStockMin = new \Kendo\Data\DataSourceAggregateItem(); $unitsInStockMin->field("UnitsInStock")->aggregate("min"); $unitsInStockMax = new \Kendo\Data\DataSourceAggregateItem(); $unitsInStockMax->field("UnitsInStock")->aggregate("max"); $unitsInStockCount = new \Kendo\Data\DataSourceAggregateItem(); $unitsInStockCount->field("UnitsInStock")->aggregate("count"); $group = new \Kendo\Data\DataSourceGroupItem(); $group->field('UnitsInStock')->addAggregate($productNameCount, $unitsOnOrderAvg, $unitsInStockMin, $unitsInStockMax, $unitsInStockCount); $dataSource = new \Kendo\Data\DataSource(); $dataSource->transport($transport)->pageSize(7)->serverPaging(true)->serverSorting(true)->serverGrouping(true)->serverFiltering(true)->serverAggregates(true)->addGroupItem($group)->addAggregateItem($productNameCount, $unitsOnOrderAvg, $unitsInStockMin, $unitsInStockMax)->schema($schema); $grid = new \Kendo\UI\Grid('grid'); $productName = new \Kendo\UI\GridColumn(); $productName->field('ProductName')->footerTemplate('Total Count: #=count#')->groupFooterTemplate('Count: #=count#')->title('Product Name'); $unitPrice = new \Kendo\UI\GridColumn(); $unitPrice->field('UnitPrice')->format('{0:c}')->width(150)->title('Unit Price'); $unitsOnOrder = new \Kendo\UI\GridColumn(); $unitsOnOrder->field('UnitsOnOrder')->width(150)->footerTemplate('Average: #=average#')->groupFooterTemplate('Average: #=average#')->title('Units On Order'); $unitsInStock = new \Kendo\UI\GridColumn(); $unitsInStock->field('UnitsInStock')->width(150)->footerTemplate('<div>Min: #= min #</div><div>Max: #= max #</div>')->groupHeaderTemplate('Units In Stock: #= value # (Count: #= count#)')->title('Units In Stock'); $grid->addColumn($productName, $unitPrice, $unitsOnOrder, $unitsInStock)->dataSource($dataSource)->scrollable(false)->sortable(true)->pageable(true); echo $grid->render(); ?>