1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    Answers
    1
    Shady-sister is on a distinguished road

      0  

    Default Answered: Editable values don't send from Grid Panel to php-script

    Answered: Editable values don't send from Grid Panel to php-script


    Hi! I have an editable Grid using php+mysql. When I try to edit cell, I have an empty $_POST.
    Scrinshot from firebug (+ result from edit.php with var_dump($_POST)):
    1.jpg
    2.jpg
    view.js:
    Code:
    Ext.onReady(function() {    var cols = [
        { dataIndex: 'id', header: 'id', hidden: true },
        { dataIndex: 'title', header: 'Title', width: 200, editor: 'textfield' },
        { dataIndex: 'author', header: 'Author', width: 200, editor: 'textfield' },
        { dataIndex: 'isbn', header: 'ISBN', width: 100, editor: 'numberfield' },
    ],
    
    
        fields = [];
            for(var i=0; i<cols.length; i++) {
            fields.push(cols[i].dataIndex);
        }
    
    
    Ext.define('Book', {
        extend: 'Ext.data.Model',
        fields: fields
    });
    
    
    var store = Ext.create('Ext.data.JsonStore', {
        model: 'Book',
        proxy: {
            type: 'ajax',
            actionMethods: {
                create: 'POST',
                read: 'POST',
                update: 'POST',
                destroy: 'POST'
            },
            api:{
            read: 'view.php',
            update: 'edit.php'
            }},
            reader: {
                type: 'json'
                //root: 'data' 
            },
            writer: new Ext.data.writer.Json({
                writeAllFields: true
           })
            
    });
    
    
    Ext.create('Ext.grid.Panel', {
        columns: cols,
        tbar: [
              {
                text: 'Save',
                handler: function(){
                    //var up = getUpdatedRecords();
                    store.sync()
                }
            }
        ],
    
    
        width: 520,
        style: 'margin-top: 5%; margin-left: 35%',
        plugins: [
            Ext.create('Ext.grid.plugin.CellEditing', {
                clicksToEdit: 2
            })
        ],
        renderTo: Ext.getBody(),
        store: store
    });
    store.load();
    
    
    });


    view.php
    PHP Code:
    <?php
    require_once 'db.php';
    $result mysql_query('SELECT * FROM books');
    while (
    $row mysql_fetch_assoc($result)) {
        for (
    $i=0$i mysql_num_fields($result); $i++) {       
     
    $meta mysql_fetch_field($result$i);        }    
    $rows[] = $row;
    }
    print (
    json_encode($rows));

    ?>
    edit.php
    PHP Code:
    <?php
    require_once 'db.php';   
     
    ini_set('display_errors'1);error_reporting(E_ALL);
    var_dump($_POST);?>
    Help me please with my problem! Thank you.

  2. PHP Code:
    Ext.create('Ext.grid.plugin.CellEditing', {            clicksToEdit2,            listeners: {                'edit': function (editor,e) {                    var grid e.grid;                    var record e.record;                    /*console.log(record.data.id);                    console.log(record.data.title);                    console.log(record.data.author);                    console.log(record.data.isbn);                    var res = [];                    res.push(record.data.id);                    res.push(record.data.title);                    res.push(record.data.author);                    res.push(record.data.isbn);                    console.log(res);*/                    Ext.Ajax.request({                        url'edit.php',                        method'POST',                        params: {                            idrecord.data.id,                            titlerecord.data.title,                            authorrecord.data.author,                            isbnrecord.data.isbn                        }                    }                )}            } 

  3. #2
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    Answers
    1
    Shady-sister is on a distinguished road

      0  

    Default Fixed

    Fixed


    PHP Code:
    Ext.create('Ext.grid.plugin.CellEditing', {            clicksToEdit2,            listeners: {                'edit': function (editor,e) {                    var grid e.grid;                    var record e.record;                    /*console.log(record.data.id);                    console.log(record.data.title);                    console.log(record.data.author);                    console.log(record.data.isbn);                    var res = [];                    res.push(record.data.id);                    res.push(record.data.title);                    res.push(record.data.author);                    res.push(record.data.isbn);                    console.log(res);*/                    Ext.Ajax.request({                        url'edit.php',                        method'POST',                        params: {                            idrecord.data.id,                            titlerecord.data.title,                            authorrecord.data.author,                            isbnrecord.data.isbn                        }                    }                )}            } 

Tags for this Thread