This is a migrated thread and some comments may be shown as answers.

update or create not working

2 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karamat
Top achievements
Rank 1
Karamat asked on 14 Jun 2017, 03:11 PM

this is the code that I am using for update or  create but when starting for edit or create and  the bottom name changed to update nothing is working till pressing cancel.

<?php
require_once 'config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    header('Content-Type: application/json');
}

$inputJSON = file_get_contents('php://input');
$paredData = json_decode($inputJSON, TRUE);

$pn= $paredData["filed1"];
$sc = $paredData["filed2"];


/**
 * connect to database and execute sqql command
 */
 $tableName = '********'  ;

$conn = oci_connect($dbuser, $dbpassword , $dbhost.':'.$dbport.'/'.$dbname);        

$sqlStatement = 'insert into '.$tableName.'(pn, SC) VALUES ('.$PN.', '.$sc.'.');';
echo $sqlStatement;
$retrive = oci_parse($conn , $sqlStatement);
$execute = oci_execute($retrive);

if ($execute){
    echo 'successful';
    oci_commit($conn);
    LogerFile($databaseLogEvents,$partNo.' inserted Succesfuly. ');
    } else {
    echo ' error';
    oci_rollback($conn);
    LogerFile($errorLogEvents,$partNo.' has been Rolleback something went wrong for inserting. ');
    }

2 Answers, 1 is accepted

Sort by
0
Karamat
Top achievements
Rank 1
answered on 14 Jun 2017, 03:17 PM

just forgot to put the grid code.

$read = new \Kendo\Data\DataSourceTransportRead();
$read->url('readApi.php')
     ->contentType('application/json')
     ->type('POST');

$update = new \Kendo\Data\DataSourceTransportUpdate();
$update->url('updateApi.php')
     ->contentType('application/json')
     ->type('POST');

$destroy = new \Kendo\Data\DataSourceTransportDestroy();
$destroy->url('deleteApi.php')
     ->contentType('application/json')
     ->type('POST');

$creat = new \Kendo\Data\DataSourceTransportCreate();
$creat->url('createApi.php')
     ->contentType('application/json')
     ->type('POST');

$transport = new \Kendo\Data\DataSourceTransport();
$transport 
        ->create($creat)
        ->read($read)
        ->update($update)
        ->destroy($destroy);
 //       ->parameterMap('mapParamsToJSON');

/*
 *  create data Model 
 */
$model = new \Kendo\Data\DataSourceSchemaModel();

$pn= new \Kendo\Data\DataSourceSchemaModelField('PN');
$pn->type('string');

$sc = new \Kendo\Data\DataSourceSchemaModelField('SC');
$sc->type('string');

       
$model
         ->id("ID")
      ->addField($pn)
      ->addField($sc);
$schema = new \Kendo\Data\DataSourceSchema();

$schema->model($model);

$dataSource = new \Kendo\Data\DataSource();

$dataSource->transport($transport)
           ->pageSize(17)
           ->schema($schema);

$orderID = new \Kendo\UI\GridColumn();
$orderID->field('PN')
          //  ->filterable(true)
            ->title('pnO');

 

$freight = new \Kendo\UI\GridColumn();
$freight->field('SC');
         
$orderDate = new \Kendo\UI\GridColumn();
$orderDate->field('ISPT');


$editCommand = new \Kendo\UI\GridColumnCommandItem();
$editCommand->name('edit')
        ->text('Edit');

$destroycommand = new \Kendo\UI\GridColumnCommandItem();
$destroycommand->name('destroy')
        ->text('Delete');

$commandColumn  = new \Kendo\UI\GridColumn();
$commandColumn
        ->addCommandItem($editCommand)
        ->addCommandItem($destroycommand);
        
$create = new \Kendo\UI\GridToolbarItem('create');
$grid = new \Kendo\UI\Grid('grid');
$grid
        ->addToolbarItem($create)
        ->addColumn($orderID)
        ->addColumn($commandColumn)       
     ->dataSource($dataSource)
     ->sortable(true)
   //  ->height(750)
     ->filterable(true)
     ->pageable(true)
      ->editable('inline');

echo $grid->render();

 

 


0
Stefan
Telerik team
answered on 16 Jun 2017, 07:53 AM
Hello Karamat,

This is not a known issue and it can be caused by different factors.

I noticed that the ID field is not created in the DataSourceSchemaModelField.

Also, in order to help us determine the issue, please advise if there are any errors in the browser console.

Additionally, I noticed that the Transport create is named $creat, check is setting it to create will change the behaviour.

Please check our runnable with the Grid with inline editing for the expected configuration:

http://demos.telerik.com/php-ui/grid/editing-inline

If additional assistance is needed, please provide an information about potential errors in the console, and if possible screencast of the issue, so we can investigate further.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Tags
Grid
Asked by
Karamat
Top achievements
Rank 1
Answers by
Karamat
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or