Problems with POST/GET and JSON with GridPanel, FormPanel, PHP

Posted on Jan 08, 2009 under xn--zqqs84h3is.com | edit
  • Hello All,

    I have a employee info Grid Panel with 3 buttons (add employee, edit employee, delete employee). The Grid displays data perfectly but I am having problems getting the POST and GET vars sent/received on the PHP side. I am very new to Extjs and have gathered all this through examples found online. Please forgive my lack of knowledge in this if noticed. I have tried to include all the code that I use and some desc too.
    Add Employee button loads a FormPanel that posts some JSON data to a AddEmployee.php file.
    Edit Employee button loads a FormPanel that posts some JSON data to a EditEmployee.php file, but this time carrying the needed Emp_ID for which it was edited.
    Deleted Employee button posts JSON data to DeleteEmployee.php along with the Emp_ID that needs deletion.So, my PHP files somehow doesn't seem to be collecting / accepting any POST values. I noticed that FireBug has all the necessary JSON going out and coming in. But since I am so bummed about this I decided to post this online for some expert advice.

    I have pasted below my emp.js, emp.html, GetEmployeePaging.php, GetEmployee.php and GetDeptList.php. I have also included the DB Schema for any clarifications. Any help on this will be greatly appreciated!!!! Thanks!!


    DB info:



    --
    -- Table structure for table `emp_china`
    --

    CREATE TABLE `emp_china` (
    `EmployeeID` int(10) NOT NULL,
    `CnName` varchar(255) NOT NULL,
    `Sex` varchar(255) NOT NULL,
    `Age` varchar(255) NOT NULL,
    `Email` varchar(255) NOT NULL,
    `OnWorkDate` varchar(255) NOT NULL,
    `DeptName` varchar(255) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `emp_china`
    --

    INSERT INTO `emp_china` VALUES (1, 'Birmy', '1', '26', 'birmy@birmy.com', '2008-03-03', 'SEO');
    INSERT INTO `emp_china` VALUES (2, 'Nimal', '1', '26', 'nimal@nimal.com', '2008-02-02', 'SAT');

    --
    -- Table structure for table `dept_china`
    --

    CREATE TABLE `dept_china` (
    `DeptID` int(10) NOT NULL,
    `DeptName` varchar(255) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `dept_china`
    --

    INSERT INTO `dept_china` VALUES (1, 'SEO');
    INSERT INTO `dept_china` VALUES (2, 'SAT');


    emp.js:


    Ext.onReady(function(){

    // create the Data Store
    var store = new Ext.data.Store({
    // load using script tags for cross domain, if the data in on the same domain as
    // this page, an HttpProxy would be better
    proxy: new Ext.data.WCFHttpProxy({
    url: 'GetEmployeePaging.php'
    }),

    // create reader that reads the Topic records
    reader: new Ext.data.WCFJsonReader({
    root: 'EmployeeList',
    totalProperty: 'TotalCount',
    id: 'EmployeeID',
    fields: [
    {name: 'EmployeeID', type: 'int'},
    {name: 'CnName', type: 'string'},
    {name: 'Sex', type: 'string'},
    {name: 'Age', type: 'int'},
    {name: 'Email', type: 'string'},
    {name: 'OnWorkDate',type:'string'},
    {name: 'DeptName', type: 'string'}
    ]
    }),

    // turn on remote sorting
    remoteSort: true
    });

    store.setDefaultSort('EmployeeID', 'ASC');

    function renderSex(value, p, record){
    return record.data.Sex=="true"?"Male":"Female";
    }
    function renderOnWorkDate(value, p, record){
    var jsondate = record.data.OnWorkDate;
    return eval("new " + jsondate.substr(1,jsondate.length-2)).toLocaleDateString();
    }

    // the column model has information about grid columns
    // dataIndex maps the column to the specific data field in
    // the data store
    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel(); // add checkbox column

    var cm = new Ext.grid.ColumnModel([nm,sm,{
    header: "Employee ID",
    dataIndex: 'EmployeeID',
    width: 100
    //renderer: renderTopic
    },{
    header: "Name",
    dataIndex: 'CnName',
    width: 200
    },{
    header: "Sex",
    dataIndex: 'Sex',
    width: 70,
    renderer: renderSex
    },{
    header: "Age",
    dataIndex: 'Age',
    width: 70

    },{
    header: "Email",
    dataIndex: 'Email',
    width: 150
    },{
    header: "Join Date",
    dataIndex: 'OnWorkDate',
    width: 150
    //renderer: renderOnWorkDate
    },{
    header: "Department",
    dataIndex: 'DeptName',
    width: 200

    }]);

    // by default columns are sortable
    cm.defaultSortable = true;

    var grid = new Ext.grid.GridPanel({
    //el:'topic-grid',
    renderTo: document.body,
    width:800,
    height:500,
    title:'Employee Info',
    store: store,
    cm: cm,
    trackMouseOver:false,
    sm: sm,
    loadMask: true,
    viewConfig: {
    forceFit:true,
    enableRowBody:true,
    showPreview:true,
    getRowClass : function(record, rowIndex, p, store){

    return 'x-grid3-row-collapsed';
    }
    },
    // inline toolbars
    tbar:[{
    text:'Add Employee',
    tooltip:'tip',
    iconCls:'add',
    handler:handleAdd
    }, '-', {
    text:'Edit Employee',
    tooltip:'tip',
    iconCls:'option',
    handler:handleEdit
    },'-',{
    text:'Delete Employee',
    tooltip:'tip',
    iconCls:'remove',
    handler:handleDelete
    }],
    bbar: new Ext.PagingToolbar({
    pageSize: 25,
    store: store,
    displayInfo: true
    })
    });

    // render it
    grid.render();


    // trigger the data store load
    var request={start:0,limit:25};
    store.load({params:request});

    //??????
    var deptDs = new Ext.data.Store({
    proxy: new Ext.data.WCFHttpProxy({
    url:'GetDeptList.php'
    }),
    reader: new Ext.data.WCFJsonReader({
    root: 'DeptList',
    id: 'DeptID'
    }, [ 'DeptID', 'DeptName']
    ),
    remoteSort: false
    });


    //??????
    var EmpForm = new Ext.FormPanel({
    frame: true,
    labelAlign: 'right',
    labelWidth: 120,
    width: 450,
    height:250,
    items: new Ext.form.FieldSet({
    title: 'Employee Id',
    autoHeight: true,
    defaults: {width: 200},
    defaultType: 'textfield',
    items: [new Ext.form.Hidden({
    name: 'EmployeeID'
    }),{
    fieldLabel: 'Name',
    name: 'CnName',
    allowBlank:false
    },new Ext.form.ComboBox({
    fieldLabel: 'Sex',
    hiddenName:'Sex',
    store: new Ext.data.SimpleStore({
    fields: ['value', 'text'],
    data : [[1,'Male'],[0,'Female']]
    }),
    valueField:'value',
    displayField:'text',
    typeAhead: true,
    mode: 'local',
    triggerAction: 'all',
    selectOnFocus:true,
    allowBlank:false
    }),new Ext.form.NumberField({
    fieldLabel: 'Age',
    name: 'Age'
    }), {
    fieldLabel: 'Email',
    name: 'Email',
    vtype:'email'
    }, new Ext.form.DateField({
    fieldLabel: 'Join Date',
    name: 'OnWorkDate',
    allowBlank:false,
    format : "Y-m-d"
    }), new Ext.form.ComboBox({
    fieldLabel: 'Department',
    name: 'DepartmentName',
    hiddenName: 'DepartmentID',
    store: deptDs,
    valueField: 'DeptID',
    displayField: 'DeptName',
    typeAhead: true,
    mode: 'remote',
    triggerAction: 'all',
    emptyText: 'Select Dept',
    selectOnFocus: true,
    allowBlank: false
    })
    ]
    })
    });


    function handleAdd(){
    var AddEmpWin = new Ext.Window({
    title: 'Add Employee',
    layout:'fit',
    width:500,
    height:300,
    plain: true,
    items:EmpForm,
    buttons: [{
    text:'Add Employee',
    handler: AddRecord
    },{
    text: 'Cancel',
    handler: function(){
    AddEmpWin.hide();
    }
    }]
    });
    AddEmpWin.show(this);
    }
    function handleEdit(){
    var selectedKeys = grid.selModel.selections.keys; //returns array of selected rows ids only
    if(selectedKeys.length != 1){
    Ext.MessageBox.alert('None Selected','Please select at least one record!');
    }
    else {
    var EditEmpWin = new Ext.Window({
    title: 'Update Employee',
    layout:'fit',
    width:500,
    height:300,
    plain: true,
    items:EmpForm,
    buttons: [{
    text:'Update Employee',
    handler: UpdateRecord
    },{
    text: 'Cancel',
    handler: function(){
    EditEmpWin.hide();
    }
    }]
    });
    EditEmpWin.show(this);
    //Ext.MessageBox.alert("??",selectedKeys);
    deptDs.load(); //??????
    var request = {empID:selectedKeys[0]};
    Ext.MessageBox.show({
    msg: 'Opening Emp Data:',
    progressText: 'Opening...',
    width:300,
    wait:true,
    waitConfig: {interval:200}
    });
    Ext.Ajax.request({
    url: 'GetEmployee.php', //url to server side script
    method: 'POST',
    params:Ext.util.JSON.encode(request),//the unique id(s)
    callback: function (options, success, response) {
    if (success) { //success will be true if the request succeeded
    Ext.MessageBox.hide();
    var formvalue=ConvertResponseText(response.responseTex t,"OnWorkDate",true,true);
    EmpForm.form.setValues(formvalue);
    } else {
    Ext.MessageBox.hide();
    Ext.MessageBox.alert("Some Alert,???",response.responseText);
    }
    },
    //the function to be called upon failure of the request (server script, 404, or 403 errors)
    failure:function(response,options){
    Ext.MessageBox.hide();
    ReturnValue = Ext.MessageBox.alert("Failed!","??????!??????!");
    },
    success:function(response,options){
    Ext.MessageBox.hide();
    }
    })// end Ajax request
    }
    }
    function UpdateRecord(btn)
    {
    if (EmpForm.form.isValid()) {
    btn.disabled=true;
    Ext.MessageBox.show({
    msg: 'Updating Employee:, ???',
    progressText: 'Updating...',
    width:300,
    wait:true,
    waitConfig: {interval:200}
    });
    var formvalue = EmpForm.form.getValues();
    var request = {emp:ConvertFormValue(formvalue,'OnWorkDate')};
    // Ext.MessageBox.alert("Yo",formvalues[1]);
    Ext.Ajax.request({
    url: 'UpdateEmployee.php', //url to server side script
    method: 'POST',
    params:Ext.util.JSON.encode(request),//the unique id(s)
    callback: function (options, success, response) {
    if (success) { //success will be true if the request succeeded
    Ext.MessageBox.hide();
    var alertcontent=ConvertResponseText(response.response Text,"",true,false);
    Ext.MessageBox.alert("Updated!",alertcontent);
    } else {
    Ext.MessageBox.hide();
    Ext.MessageBox.alert("Some Alert,???",response.responseText);
    }
    },
    //the function to be called upon failure of the request (server script, 404, or 403 errors)
    failure:function(response,options){
    Ext.MessageBox.hide();
    ReturnValue = Ext.MessageBox.alert("Failed!","??????!??????!");
    },
    success:function(response,options){
    Ext.MessageBox.hide();
    store.reload();
    }
    })// end Ajax request
    }
    }

    function AddRecord(btn)
    {
    if (EmpForm.form.isValid()) {
    btn.disabled=true;
    Ext.MessageBox.show({
    msg: 'Adding Employee:, ???',
    progressText: 'Adding...',
    width:300,
    wait:true,
    waitConfig: {interval:200}
    });
    var formvalue = EmpForm.form.getValues();
    var request = {emp:ConvertFormValue(formvalue,'OnWorkDate')};
    //Ext.MessageBox.alert("??",formvalues);
    Ext.Ajax.request({
    url: 'AddEmployee.php', //url to server side script
    method: 'POST',
    params:Ext.util.JSON.encode(request),//the unique id(s)
    callback: function (options, success, response) {
    if (success) { //success will be true if the request succeeded
    Ext.MessageBox.hide();
    var alertcontent=ConvertResponseText(response.response Text,"",true,false);
    Ext.MessageBox.alert("Added!",alertcontent);
    } else {
    Ext.MessageBox.hide();
    Ext.MessageBox.alert("Some Alert,???",response.responseText);
    }
    },
    //the function to be called upon failure of the request (server script, 404, or 403 errors)
    failure:function(response,options){
    Ext.MessageBox.hide();
    ReturnValue = Ext.MessageBox.alert("Failed!","??????!??????!");
    },
    success:function(response,options){
    Ext.MessageBox.hide();
    store.reload();
    }
    })// end Ajax request

    }
    }

    function handleDelete(){
    var selectedKeys = grid.selModel.selections.keys; //returns array of selected rows ids only
    if(selectedKeys.length > 0)
    {
    Ext.MessageBox.confirm('Delete Employee:','Are you sure you want to delete row no:' + selectedKeys + '?!?!', deleteRecord);
    }
    else
    {
    Ext.MessageBox.alert('None Selected','Please select at least one record!');
    }//end
    }

    function deleteRecord(btn){
    if(btn=='yes'){
    var selectedRows = grid.selModel.selections.items;//returns record objects for selected rows (all info for row)
    var selectedKeys = grid.selModel.selections.keys;
    //var deleteresult = AjaxRequest('DelEmployee.php',selectedKeys,false,"")
    Ext.MessageBox.show({
    msg: 'Deleting rows: ' + selectedKeys,
    progressText: 'Deleting...',
    width:300,
    wait:true,
    waitConfig: {interval:200}
    });
    Ext.Ajax.request({
    url: 'DelEmployee.php', //url to server side script
    method: 'POST',
    params:Ext.util.JSON.encode(selectedKeys),//the unique id(s)
    //params:selectedKeys,//the unique id(s)
    callback: function (options, success, response) {
    if (success) { //success will be true if the request succeeded
    Ext.MessageBox.hide();
    var alertcontent=ConvertResponseText(response.response Text,"",false,false);
    Ext.MessageBox.alert("Deleted!",alertcontent);
    } else {
    Ext.MessageBox.hide();
    Ext.MessageBox.alert("Some Alert,???",response.responseText);
    }
    },
    //the function to be called upon failure of the request (server script, 404, or 403 errors)
    failure:function(response,options){
    Ext.MessageBox.hide();
    ReturnValue = Ext.MessageBox.alert("Failed!","??????!??????!");
    },
    success:function(response,options){
    Ext.MessageBox.hide();
    store.reload();
    }
    })// end Ajax request
    }//end if click 'yes' on button
    } // end deleteRecord



    });
    GetEmployeePaging.php:



    $user='root'; //user
    $pw='xxx'; //user password
    $db='xxx'; //name of database
    $table='emp_china'; //name of table data stored in

    //make database connection
    $connection = mysql_connect("localhost", $user, $pw) or die("Could not connect: " . mysql_error());
    //select DB
    mysql_select_db($db) or die("Could not select database");

    // This is just a code fragment from a larger PHP server-side script
    //require_once('JSON.php');

    //$json = new Services_JSON();

    // accept POST data and decode it
    //$value = $json->decode($GLOBALS['HTTP_RAW_POST_DATA']);

    // Now work with value as raw PHP



    function showData()
    {
    $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_POST['start']);
    $end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_POST['limit']);

    $sql_count = 'SELECT * FROM ' . emp_china . '';
    $sql = '' . $sql_count . ' LIMIT ' . $start . ', '. $end . '';

    $result_count = mysql_query($sql_count);
    $rows = mysql_num_rows($result_count);

    $result = mysql_query($sql_count);

    while($rec = mysql_fetch_array($result, MYSQL_ASSOC)){
    //these lines are to populate the tax column for the initial display
    //of the grid, any updates to the price are handled by another function below
    //$price = $rec['price'];
    //$rec['tax'] = round($price * ($taxRate),2);

    $arr = $rec;
    };

    if (version_compare(PHP_VERSION,"5.2","<"))
    {
    require_once("./JSON.php"); //if php<5.2 need JSON class
    $json = new Services_JSON();//instantiate new json object
    $data=$json->encode($arr); //encode the data in json format
    } else
    {
    $data = json_encode($arr); //encode the data in json format
    }

    /* If using ScriptTagProxy: In order for the browser to process the returned
    data, the server must wrap te data object with a call to a callback function,
    the name of which is passed as a parameter by the ScriptTagProxy. (default = "stcCallback1001")
    If using HttpProxy no callback reference is to be specified*/
    $cb = isset($_POST['callback']) ? $_POST['callback'] : '';

    $cb = isset($_POST['callback']) ? $_POST['callback'] : '';

    echo $cb . '({"TotalCount":"' . $rows . '","EmployeeList":' . $data . '})';
    }

    showData();

    ?>
    GetDeptList.php:




    $user='root'; //user
    $pw='xxx'; //user password
    $db='xxx'; //name of database
    $table='dept_china'; //name of table data stored in

    //make database connection
    $connection = mysql_connect("localhost", $user, $pw) or die("Could not connect: " . mysql_error());
    //select DB
    mysql_select_db($db) or die("Could not select database");

    function showData()
    {
    $start = (integer) (isset($_GET['start']) ? $_GET['start'] : $_GET['start']);
    $end = (integer) (isset($_GET['limit']) ? $_GET['limit'] : $_GET['limit']);

    $sql_count = 'SELECT * FROM ' . dept_china;
    $sql = $sql_count . ' LIMIT ' . $start . ', '. $end;

    $result_count = mysql_query($sql_count);
    $rows = mysql_num_rows($result_count);

    $result = mysql_query($sql_count);

    while($rec = mysql_fetch_array($result, MYSQL_ASSOC)){
    //these lines are to populate the tax column for the initial display
    //of the grid, any updates to the price are handled by another function below
    //$price = $rec['price'];
    //$rec['tax'] = round($price * ($taxRate),2);

    $arr = $rec;
    };

    if (version_compare(PHP_VERSION,"5.2","<"))
    {
    require_once("./JSON.php"); //if php<5.2 need JSON class
    $json = new Services_JSON();//instantiate new json object
    $data=$json->encode($arr); //encode the data in json format
    } else
    {
    $data = json_encode($arr); //encode the data in json format
    }

    /* If using ScriptTagProxy: In order for the browser to process the returned
    data, the server must wrap te data object with a call to a callback function,
    the name of which is passed as a parameter by the ScriptTagProxy. (default = "stcCallback1001")
    If using HttpProxy no callback reference is to be specified*/
    $cb = isset($_GET['callback']) ? $_GET['callback'] : '';

    echo $cb . '({"TotalCount":"' . $rows . '","DeptList":' . $data . '})';
    }

    showData();



    ?>

    GetEmployee.php:



    $user='root'; //user
    $pw='xxx'; //user password
    $db='xxx'; //name of database
    $table='emp_china'; //name of table data stored in

    //make database connection
    $connection = mysql_connect("localhost", $user, $pw) or die("Could not connect: " . mysql_error());
    //select DB
    mysql_select_db($db) or die("Could not select database");

    function showData()
    {
    $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_POST['start']);
    $end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_POST['limit']);

    $sql_count = "SELECT * FROM emp_china WHERE EmployeeID = ".$_POST['empID']."";
    $sql = $sql_count . ' LIMIT ' . $start . ', '. $end;

    $result_count = mysql_query($sql_count);
    $rows = mysql_num_rows($result_count);

    $result = mysql_query($sql_count);

    while($rec = mysql_fetch_array($result, MYSQL_ASSOC)){
    //these lines are to populate the tax column for the initial display
    //of the grid, any updates to the price are handled by another function below
    //$price = $rec['price'];
    //$rec['tax'] = round($price * ($taxRate),2);

    $arr = $rec;
    };

    if (version_compare(PHP_VERSION,"5.2","<"))
    {
    require_once("./JSON.php"); //if php<5.2 need JSON class
    $json = new Services_JSON();//instantiate new json object
    $data=$json->encode($arr); //encode the data in json format
    } else
    {
    $data = json_encode($arr); //encode the data in json format
    }

    /* If using ScriptTagProxy: In order for the browser to process the returned
    data, the server must wrap te data object with a call to a callback function,
    the name of which is passed as a parameter by the ScriptTagProxy. (default = "stcCallback1001")
    If using HttpProxy no callback reference is to be specified*/
    $cb = isset($_POST['callback']) ? $_POST['callback'] : '';

    echo $cb . '({"TotalCount":"' . $rows . '","EmployeeList":' . $data . '})';
    }

    showData();

    ?>



    GetEmployeePaging POST / RESPONSE:


    POST:

    {"start":0,"limit":25,"sort":"EmployeeID","dir":"ASC"}

    RESPONSE:

    ({"TotalCount":"2","EmployeeList":[{"EmployeeID":"1","CnName":"Birmy","Sex":"1","Age":"26","Email":"birmy@india.com","OnWorkDate":"2008-03-03","DeptName":"SEO"},{"EmployeeID":"2","CnName":"Nimal","Sex":"1","Age":"26","Email":"nimal@india.com","OnWorkDate":"2008-02-02","DeptName":"SAT"}]})


    GetDeptList.php POST / RESPONSE:



    POST:

    {}

    RESPONSE:

    ({"TotalCount":"2","DeptList":[{"DeptID":"1","DeptName":"SEO"},{"DeptID":"2","DeptName":"SAT"}]})



    GetEmployee.php POST / RESPONSE:



    POST:

    {"empID":"2"}

    RESPONSE:

    ({"TotalCount":"","EmployeeList":null})


    WCFHttpProxy.js



    Ext.data.WCFHttpProxy = Ext.extend(Ext.data.HttpProxy,{

    load : function(params, reader, callback, scope, arg){
    if(this.fireEvent("beforeload", this, params) !== false){

    Ext.lib.Ajax.defaultPostHeader = 'application/json';
    params = Ext.util.JSON.encode(params);
    var o ={
    params : params {},
    request:{
    callback : callback,
    scope : scope,
    arg : arg
    },
    reader: reader,
    callback : this.loadResponse,
    scope: this
    };
    if(this.useAjax){
    Ext.applyIf(o, this.conn);
    if(this.activeRequest){
    Ext.Ajax.abort(this.activeRequest);
    }
    this.activeRequest = Ext.Ajax.request(o);
    }else{
    this.conn.request(o);
    }
    }else{
    callback.call(scopethis, null, arg, false);
    }
    }
    });



    WCFJsonReader.js



    /**
    * @class Ext.data.WCFJsonReader
    * @extends Ext.data.JsonReader
    *
    * Custom reader for reading data from WCF. If you are using WebMessageBodyStyle.Wrapped, then WCF adds a root object to your
    * JSON result:
    *
    * { "MethodResult": { "Count" : 0, "Objects": [ … ] } }
    *
    * Ext does not expect the result to have a root object before parsing, so this class will remove it.
    */
    Ext.data.WCFJsonReader = Ext.extend(Ext.data.JsonReader,{
    /**//* @cfg {Boolean} Sets whether or not the OperationContract has the is using WebMessageBodyStyle.Wrapped */
    wrapped: true,
    /**//**
    * If wrapped is set to true, we will strip WCF’s wrap object
    */
    read : function(response){
    var json = response.responseText;

    var o = eval("("+json+")");
    if(!o){
    throw{message: "JsonReader.read: Json object not found"};
    }
    if (this.wrapped){
    for (var prop in o){
    if (typeof(prop) == 'string' && prop.substr(prop.length-6,prop.length) == 'Result'){
    o = this.convert(o[prop]);
    //o = o[prop];
    break;
    }
    }
    }
    if(o.metaData){
    delete this.ef;
    this.meta = o.metaData;
    this.recordType = Ext.data.Record.create(o.metaData.fields);
    this.onMetaChange(this.meta, this.recordType, o);
    }
    return Ext.data.WCFJsonReader.superclass.readRecords.call (this, o);
    },
    //private
    convert : function(o){
    o = eval("("+o+")");
    var newResult = new Object();
    for (var rootProp in o){
    newResult[rootProp] = o[rootProp];
    }
    return newResult;
    }
    });


  • Hello MJ,

    Thanks for the help offered, I picked this example from the web, it was this Chinese site with chinese all over it, this example used WCF instead of normal HttpProxy. Well, not that I could read all that was posted there, but a practical learner that I am it surely got me started :)

    I followed your instructions and have pasted the Console log below:


    inside add record, arguments = [Object initialConfig=Object minWidth=75 hideParent=true, Object browserEvent=Event click button=0 type=click]
    form is valid block
    inside add record, request = Object emp=Object


    AddEmployee.php POST/RESPONSE:


    POST:
    {"emp":{"CnName":"some name","Sex":"1","Age":"22","Email":"someemail@somewebsite.com","OnWorkDate":"/Date(1204588800000

    )/","DepartmentID":"1"}}


    Also, the other thing I noticed was when you select a row and hit 'Edit Employee' btn, the form loads (with no data in it obviously) and then I choose to not to enter any data and close the window (Close, Cancel) and then with the same row selected I hit the 'Edit Employee' btn again but this time only the window loads without the form in it. Can you please tell me what might be wrong in this case?

    I am searching all possible forums on various sites also to see if I can find a working example of such a case, where there is a grid and then rowclick loads a formpanel with more details for the employee. basically a app with add, edit and delete capabilities.

    again, a BIG! thanks for the help offered


  • Why are you using WCF instead of typical proxy/reader?

    Can we break this down and isolate it to one feature at a time?

    I picked at random the add record.


    function AddRecord(btn)
    {
    console.log('inside add record, arguments =',arguments);
    if (EmpForm.form.isValid()) {
    console.log('form is valid block');
    btn.disabled=true;
    Ext.MessageBox.show({
    msg: 'Adding Employee:, ???',
    progressText: 'Adding...',
    width:300,
    wait:true,
    waitConfig: {interval:200}
    });
    var formvalue = EmpForm.form.getValues();
    var request = {emp:ConvertFormValue(formvalue,'OnWorkDate')};
    //Ext.MessageBox.alert("??",formvalues);
    console.log('inside add record, request =',request);
    Ext.Ajax.request({
    url: 'AddEmployee.php', //url to server side script
    method: 'POST',
    params:Ext.util.JSON.encode(request),//the unique id(s)
    callback: function (options, success, response) {


    What does firebug show for the POST and response when you try to add record now? What does the console log show?


  • What you're doing is basically the same as I've done in my grid example. You've just added an itermediate step on the js side (loading another form and submitting from it).

    So it looks like your add form is sending data to your server. I don't understand what your question is now. Looks like you'll need to decode the json object server side and work with that form data as needed.

    If you don't know what that reader/proxy is suggest you just use the one provided with ext.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Problems with POST/GET and JSON with GridPanel, FormPanel, PHP , Please add it free.