Our state of the art Gantt chart


Post by arcady »

It's hard to say without seeing the code. We need a proper runnable test case to assist you.

Post by sravanthi chakilam »

I will try to explain the problem I am facing please excuse if anything wrong. I did not change any code first and I have tired by updating the Name of the project by adding autosync: true then I am getting the error
Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\jmsdemo\gantt-1.0.2-trial\examples\php\php\Bryntum\CRUD\SyncHandler.php on line 109
{"success":false,"requestId":"15604977034752","message":"Cannot update server revision stamp.","code":6}
So I have cross verify the code in SyncHandler.php
$mode == ADDED_AND_UPDATED_ROWS
is calling handleAdded function so I have removed that one .
 public function handle($request, $mode = ALL_ROWS)
    {
        $res = array();

        if ($mode == ALL_ROWS || $mode == META_DATA) {
            $this->handleMetaData($request, $res);
        }

        if ($mode == ALL_ROWS || $mode == ADDED_ROWS) {
            $this->handleAdded($request, $res);
        }
        if ($mode == ALL_ROWS || $mode == UPDATED_ROWS || $mode == ADDED_AND_UPDATED_ROWS) {
            $this->handleUpdated($request, $res);
        }
        if ($mode == ALL_ROWS || $mode == REMOVED_ROWS) {
            $this->handleRemoved($request, $res);
        }

        if ($mode == ALL_ROWS) {
            if (@!$res['rows'] && @!$res['removed']) {
                throw new \Exception('No data to save.', E_APP_NO_SYNC_DATA);
            }
        }

        return $this->onHandled($res);
    }
}
Now it is going to handleUpdated updated function. below is the code for that function
 public function handleUpdated($request, &$response)
    {
        $updated = null;

        if (isset($request['updated'])) {
            $updated = array();
            foreach ($request['updated'] as $row) {
                $r = $this->update($row);
                $updated[] = $this->onRecordUpdated($row, $r);
            }
        }

        if (!$response) {
            $response = array();
        }

        if (sizeof($updated)) {
            $response['rows'] = @$response['rows'] ? array_merge((Array)$response['rows'], (Array)$updated) : $updated;
        }

        return $this->onUpdatedHandled($response);
    }

Below is the update function
public function update($table, $data, $where = null, $check_cols = true)
    {
        $cols = null;

        // if we need to restrict columns
        if ($check_cols) {
            // if array of columns provided
            if (is_array($check_cols)) {
                $cols = &$check_cols;
            } else {
                // let's get array of columns from database
                $cols = $this->getTableCols($table);
            }
        }

        $_data = [];
        $sql = "update $table set ";
        foreach ($data as $field => $value) {
            if (!$cols || isset($cols[$field])) {
                if ($value === null) {
                    $sql .= " `$field` = null,";
                } else {
                    $sql .= " `$field` = ?,";
                    $_data[] = $value;
                }
            }
        }
        $sql = rtrim($sql, ',');

        if ($where) {
            $sql .= ' where '.self::buildWhere($where, $_data);
        }

        $stmt = $this->db->prepare($sql);

        return $stmt->execute($_data);
    }
In above I have done below change
$sql .= " `$field` ='$value',";
                    $_data[] = $value;
and also in In BaseDAO.php I done changes like
 $sql .= " and `$field` = $value";
                $values[] = $value;
in below function
public static function buildWhere($where, &$values)
    {
        $sql = ' 1=1 ';

        foreach ((array)$where as $field => $value) {
            if ($value === null) {
                $sql .= " and `$field` is null";
            } elseif (is_array($value)) {
                $sql .= " and `$field` in ". self::buildWhereIn($value);
                $values = array_merge($values, $value);
            } else {
                $sql .= " and `$field` = ?";
                $values[] = $value;
            }
        }

        return $sql;
    }
and tired again I can see below json response in console
success	false
requestId	15604987565382
message	Cannot update server revision stamp.
code	6
May I know what is the reason ? and also by seeing the function can you please confirm I am using correct code

Post by sravanthi chakilam »

I got to know the reason . Now Update is working . I will ask if i face any other problem while creating task

Post by sravanthi chakilam »

When I press on create button it is creating a task in database with default name NewTask . This is fine but when I am editing the same task name into other name without refreshing the page it is creating another record with updated name in database .if I refresh the page it is not happening . should I need to add anything to work this without refresh

Post by sravanthi chakilam »

And also From where I can found the popup of task information

Post by mats »

And also From where I can found the popup of task information
Please see docs: https://bryntum.com/docs/gantt/#Gantt/feature/TaskEdit

Post by mats »

When I press on create button it is creating a task in database with default name NewTask . This is fine but when I am editing the same task name into other name without refreshing the page it is creating another record with updated name in database .if I refresh the page it is not happening . should I need to add anything to work this without refresh
Probably your server is not responding in the format we expect, and you need to read the docs here:

https://bryntum.com/docs/gantt/#guides/crud_manager.md

Post by sravanthi chakilam »

Probably your server is not responding in the format we expect, and you need to read the docs here:
If that is the case it will not create a task in database when I press create a task button I guess. Actually I have turn off the
$app->checkRevision($request['revision']); in sync.php
Actual problem is not only changing the name once I created a task from Create button if edit the name or duration or changing anything in the task editor popup it is creating the multiple task instead of updating the same task. Is there any way to auto load the gantt once task is created . I have tired below but still I am facing the issue
const project = window.project = new ProjectModel({

    // Let the Project know we want to use our own Task model with custom fields / methods
	autoSync : true,
	autoLoad : true,

Post by pmiklashevich »

Hello,

autoLoad is not related to the problem you described.

autoLoad loads data as soon the store is created. Please see the docs: https://www.bryntum.com/docs/gantt/#Gantt/model/ProjectModel#config-autoLoad

In our PHP demo if you comment out code starting from line 144
//project.load().then(() => {...
and reload the page, you'll see no records in the grid.
If you add
const project = window.project = new ProjectModel({
    autoLoad : true,
you can see records are there. So autoLoad works fine.
Actual problem is not only changing the name once I created a task from Create button if edit the name or duration or changing anything in the task editor popup it is creating the multiple task instead of updating the same task. Is there any way to auto load the gantt once task is created
I've checked the latest Gantt demo and found 2 critical issues, so I cannot open TaskEditor to check your scenario.
Here they are:
https://app.assembla.com/spaces/bryntum/tickets/8712-php-demo--after-creating-a-new-task-and-saving-it-ui-is-blocked-and-it/details
https://app.assembla.com/spaces/bryntum/tickets/8715-php-demo--after-creating-a-new-task-and-saving-it-selection-is-broken/details

When 8712 is done will check your testcase and get back to you with an update. Stay tuned!

Thanks,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by sravanthi chakilam »

Hi pmiklashevich,

Is there any update related to above topic . I can't see any update in above links

Post Reply