i want use DevExtreme tools in my PHP project. But when i use the DevExtreme-PHP-Data example of Devexpress some of the functions don’t work.
What I got so far is:
I am using the DevExtreme sample (link) but when processing the data, sorting and filtering there is a lot of errors from the PHP example.
the service.php sample page :
service.php (link)
DataController.php (link)
Somehow the PHP script does work, but when processsing with the dxDataGrid I got a lot of errors.
Like this example (when tyring to sort on the column) :
I found a good example from frostushaer on github but this example also do not use the Server-Side ajax page.
Can’t find a great complete PHP ajax sample out there.
How do I use in this sample of DevExtreme extra WHERE statements in the DataController?
How do I setup another example for updating data?
<?php
require_once("../../DevExtreme/LoadHelper.php");
spl_autoload_register(array("DevExtremeLoadHelper", "LoadModule"));
use DevExtremeDbSet;
use DevExtremeDataSourceLoader;
class DataController {
private $dbSet;
public function __construct() {
//TODO: use your database credentials
$mySQL = new mysqli("serverName", "userName", "password", "databaseName");
$this->dbSet = new DbSet($mySQL, "tableName");
}
public function FillDbIfEmpty() {
if ($this->dbSet->GetCount() == 0) {
$curDateString = "2013-1-1";
for ($i = 1; $i <= 10000; $i++) {
$curDT = new DateTime($curDateString);
$curDT->add(new DateInterval("P".strval(rand(1, 1500))."D"));
$item = array(
"Name" => "Name_".strval(rand(1, 100)),
"Category" => "Category_".strval(rand(1, 30)),
"CustomerName" => "Customer_".strval(rand(1, 50)),
"BDate" => $curDT->format("Y-m-d")
);
$this->dbSet->Insert($item);
}
}
}
public function Get($params) {
$result = DataSourceLoader::Load($this->dbSet, $params);
if (!isset($result)) {
$result = $this->dbSet->GetLastError();
}
return $result;
}
public function Post($values) {
$result = $this->dbSet->Insert($values);
if (!isset($result)) {
$result = $this->dbSet->GetLastError();
}
return $result;
}
public function Put($key, $values) {
$result = NULL;
if (isset($key) && isset($values) && is_array($values)) {
if (!is_array($key)) {
$keyVal = $key;
$key = array();
$key["ID"] = $keyVal;
}
$result = $this->dbSet->Update($key, $values);
if (!isset($result)) {
$result = $this->dbSet->GetLastError();
}
}
else {
throw new Exeption("Invalid params");
}
return $result;
}
public function Delete($key) {
$result = NULL;
if (isset($key)) {
if (!is_array($key)) {
$keyVal = $key;
$key = array();
$key["ID"] = $keyVal;
}
$result = $this->dbSet->Delete($key);
if (!isset($result)) {
$result = $this->dbSet->GetLastError();
}
}
else {
throw new Exeption("Invalid params");
}
return $result;
}
}
?>
