Telerik Forums
UI for PHP Forum
5 answers
98 views

 

As on title , i have an example  grid from a mysql table, one of field was a online field, he take ( s=online or n=online)

inside  a method post if -->

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

i put this -->

        // DECODE TABLE FOR ( Online/Offline ) 
        case 'online':
            $result = $result->read('categories', $decode, $filterForOnline);
            break;

and after this -->

    if ($type != 'online') {
        $online = new DataSourceResult('mysql:host=localhost;dbname=<dbname>,<user>,<password>, $options);
        $online = $online->read('categories', $decode);
        $data = &$result['data'];

        for ($index = 0, $count = count($data); $index < $count; $index++) {
            if ($type == "create") {
                $onlineCode = $data[$index]->online;
            } else {
                $onlineCode = $data[$index]['online'];
            }
            foreach ($online['data'] as $status) {
                if ($status['code'] == $onlineCode) {
                    if ($type == "create") {
                        $data[$index]->Status = $status;
                    } else {
                        $data[$index]['Status'] = $status;
                    }
                    break;
                }
            }
        }
    }

the definition of colum is this -->

$category = new \Kendo\UI\GridColumn();
$category->field('Status')
         ->title('Status')
         ->template('#=Status.description#')
         ->editor('onlineDropDownEditor')

       ->width(180);

and the add to the grid -->

$grid->addColumn($phonenumber, $category, $idmessage, $textdata, $imagedata, $orderDate, $command)
       .....

       .....

      ->sortable(true)
     ->filterable(true)

       .....

the editor -->

function onlineDropDownEditor(container, options) {
    $('<input data-text-field="description" data-value-field="code" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: {
                schema: {
                    data: "data"
                },
                transport: {
                    read: {
                        url: "myurl.php?type=online",
                        type: "POST",
                        dataType: "json"
                    }
                }
            }
        });
    }
</script>

 

it's all working, decode, save data etc etc, 

just one think not working on that field, filtering and sorting .. how i can modify the code for have this ? 

Dimiter Topalov
Telerik team
 answered on 07 Mar 2017
4 answers
256 views

I followed all the steps, but my grid remains empty. Any help greatly appreciated.

<?php
$transport = new \Kendo\Data\DataSourceTransport();

$read = new \Kendo\Data\DataSourceTransportRead();

// Specify the url of the PHP page which will act as the remote service
$read->url('14streamPDO.php')
     ->type('POST');

$transport->read($read);

// Configure the model
$model = new \Kendo\Data\DataSourceSchemaModel();

$idField = new \Kendo\Data\DataSourceSchemaModelField('id');
$idField->type('number');

$apynoField = new \Kendo\Data\DataSourceSchemaModelField('apyno');
$apynoField->type('string');

$edadField = new \Kendo\Data\DataSourceSchemaModelField('edad');
$edadField->type('number');

$model->addField($idField)
      ->addField($apynoField)
      ->addField($edadField);

$schema = new \Kendo\Data\DataSourceSchema();

$schema->model($model);

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

// Configure data source
$dataSource->transport($transport)
           ->schema($schema);
?>


<!-- Create a kendo grid, configure its columns and set its data source.
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<?php
$grid = new \Kendo\UI\Grid('grid');

$idColumn = new \Kendo\UI\GridColumn();
$idColumn->field('id');

$apynoColumn = new \Kendo\UI\GridColumn();
$apynoColumn->field('apyno');

$edadColumn = new \Kendo\UI\GridColumn();
$edadColumn->field('edad');

// Configure columns, enable paging, filtering, sorting and grouping
$grid->addColumn($idColumn, $apynoColumn, $edadColumn)
     ->sortable(true);
?>


<!-- Output the widget echoing the render method
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<?php
  echo $grid->render();
?>

 

Code for the connection:

<?php
// set up for using PDO
$user = 'root';
$pass = 'root';
$host = 'localhost';
$db_name = 'garchazon';

// set up DSN
$dsn = "mysql:host=$host;dbname=$db_name";

$db = new PDO($dsn, $user, $pass);

$query = "SELECT id, apyno, edad FROM Employee";

$stmt = $db->prepare($query);

$stmt->execute();

$products = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Set response content type
header('Content-Type: application/json');
// Return JSON
echo json_encode($products);
?>

 

and my json output:

[{"id":"1","apyno":"Rosa Melroso","edad":"18","deporte":"Running"},{"id":"2","apyno":"Debora Melo","edad":"22","deporte":"Gym"},{"id":"3","apyno":"Debora Teste","edad":"23","deporte":"Mountain Bike"},{"id":"4","apyno":"Debora Dora de Cabezas","edad":"66","deporte":"Gym"},{"id":"5","apyno":"Rita Lazo","edad":"33","deporte":"Running"},{"id":"6","apyno":"Aquiles Bailoyo","edad":"28","deporte":"Running"},{"id":"7","apyno":"Omar Icon","edad":"21","deporte":"Running"},{"id":"8","apyno":"Paty Tasalhombro","edad":"27","deporte":"Mountain Bike"},{"id":"9","apyno":"Elber Galarga","edad":"34","deporte":"Gym"},{"id":"10","apyno":"Analisa Melchoto","edad":"55","deporte":"Gym"},{"id":"11","apyno":"Ester Mosobicho","edad":"44","deporte":"Mountain Bike"},{"id":"12","apyno":"Cindy Entes","edad":"36","deporte":"Running"},{"id":"13","apyno":"Lucila Tanga","edad":"32","deporte":"Running"},{"id":"14","apyno":"Marcelo Metio","edad":"53","deporte":"Mountain Bike"},{"id":"15","apyno":"Andy Arrea","edad":"29","deporte":"Running"},{"id":"16","apyno":"Jean Pier Napeluda","edad":"38","deporte":"Mountain Bike"},{"id":"17","apyno":"Jesica Galindo","edad":"21","deporte":"Running"},{"id":"18","apyno":"Monica Galindo","edad":"21","deporte":"Gym"},{"id":"19","apyno":"Rebeca Galindo","edad":"21","deporte":"Running"},{"id":"20","apyno":"Rosa Mile\u00f1o Ardiente","edad":"64","deporte":"Gym"},{"id":"21","apyno":"Elvio Lador","edad":"33","deporte":"Gym"},{"id":"22","apyno":"Debora Dora Dejapis","edad":"34","deporte":"Mountain Bike"},{"id":"23","apyno":"Aquiles Baeza Parada","edad":"23","deporte":"Gym"}]

Stefan
Telerik team
 answered on 02 Feb 2017
1 answer
43 views

DFWMM01:telerik.ui.for.php.2017.1.118.commercial kerteszk$ php wrappers/php/scheduler/date-grouping.php

Parse error: parse error in /Users/kerteszk/Downloads/telerik.ui.for.php.2017.1.118.commercial/wrappers/php/scheduler/date-grouping.php on line 204

There's an extra semicolon here:

        ->addView(array('type' => 'day', 'startTime' => new DateTime('2013/6/13 7:00')),
            array('type' => 'week', 'selected' => true, 'startTime' => new DateTime('2013/6/13 7:00')), 'month', 'timeline');
        ->dataSource($dataSource);

Alex Hajigeorgieva
Telerik team
 answered on 27 Jan 2017
1 answer
53 views

hello

I need an example of source code.
thank you

Dimiter Topalov
Telerik team
 answered on 26 Dec 2016
1 answer
286 views
i want to create new column for total price.
But i don't know how.
if i want add new record, The column of the total price fills automatically
I need an example of source code.
thank you
Dimiter Madjarov
Telerik team
 answered on 26 Dec 2016
2 answers
195 views
<script id="toolbar" type="text/x-kendo-template">

<div class="toolbar">
    <label class="category-label" for="category">Show products by category:</label>

    <?php

        $transport = new \Kendo\Data\DataSourceTransport();

        $read = new \Kendo\Data\DataSourceTransportRead();

        $read->url('index.php?type=read')
            ->contentType('application/json')
            ->type('POST');

        $transport->read($read)
            ->parameterMap('function(data) {
                return kendo.stringify(data);
              }');

        $schema = new \Kendo\Data\DataSourceSchema();
        $schema->data('data');

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

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




        $dropDownList = new \Kendo\UI\DropDownList('category');
        $dropDownList->dataSource($dataSource)
                ->dataTextField('RDV')
                ->dataValueField('ClientID')
                ->autoBind(false)
                ->change('categoryChange')
                ->optionLabel('All');

        echo $dropDownList->renderInTemplate();
    ?>

</div>

</script>

<script>
    function categoryChange() {
        var value = this.value(),
            grid = $("#grid").data("kendoGrid");

        if (value) {
            grid.dataSource.filter({ field: "ClientID", operator: "eq", value: parseInt(value) });
        } else {
            grid.dataSource.filter({});
        }
    }
</script>

<style>
    #grid .k-grid-toolbar
    {
        padding: .6em 1.3em;
    }
    .category-label
    {
        vertical-align: middle;
        padding-right: .5em;
    }
    #category
    {
        vertical-align: middle;
    }
    .toolbar {
        float: right;
        margin-right: .8em;
    }
</style>
Ismael Senateur
Top achievements
Rank 1
 answered on 25 Dec 2016
7 answers
172 views

Hi,

I test your examples and I want to make a table with a PopUp and a DropDownList but its not working. Is there a functional example somewhere?
Thank you.  

Larbi
Top achievements
Rank 1
 answered on 24 Nov 2016
1 answer
118 views

Hi,

I have build a nice spreadsheet with the UI for PHP.

The PHP script retrieves data from a MySQL database and populates the spreadsheet.

Now, I try to POST the spreadsheet data to another PHP script that will update the MySQL database tables.

Unfortunately I do not manage to post the spreadsheet data to the PHP script. It keeps posting an empty array.

If I use the demo version "Spreadsheet / Server Import/Export" - HTML5/JavaScript source (http://demos.telerik.com/kendo-ui/spreadsheet/server-side-import-export) and just set the "<form action='' to my PHP script, it works as a charm. But it does not post the data from the spreadsheet I created with PHP.

Does anybody knows what to do to get this working?

 

I have attached the php script.

Reinier
Top achievements
Rank 1
 answered on 06 Nov 2016
3 answers
83 views

Hi,

Just a quick question. Do you have a PHP demo of a tree view in a splitter, where the on click event changes what is in the center-pane (i.e. goes from a Grid View to loading a Map?

Not sure how this wold work considering the PHP has already run?

 

Best Regards

Tom.

Alex Gyoshev
Telerik team
 answered on 09 Sep 2016
2 answers
89 views

Hi,

 

it looks like there is a bug in the separator function of the MenuItem class (\Kendo\UI\MenuItem). It uses the variable $value which can't be passed to the function when calling it.

I am using the latest Kendo UI and UI for PHP version (2016.2.714). This is the original source code from MenuItem.php lines 42 to 48:

/**
* Specifies the item should render separator
* @return \Kendo\UI\ContextMenuItem
*/
public function separator() {
    return $this->setProperty('separator', $value);
}

 

I think that should be something like this:

/**
* Specifies the item should render separator
* @param boolean $value
* @return \Kendo\UI\ContextMenuItem
*/
public function separator($value) {
    return $this->setProperty('separator', $value);
}

 

 

Best regards

Thomas

Alex Hajigeorgieva
Telerik team
 answered on 24 Aug 2016
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?