Results 1 to 4 of 4

Thread: PHP json_encode() Data Types, Quotes

  1. #1

    Question PHP json_encode() Data Types, Quotes

    I'm programming a dynamic Grid. I use PHP's json_enode() to pass the ColumnModel options. Now, I would also like to pass a renderer. My definition in PHP looks something along the lines of:

    PHP Code:
    $colModel = array(
    'id' => 'icon',
    'header' => 'Icon',
    'width' => 40,
    'dataIndex' => 'icon',
    'renderer' => renderIcon// where renderIcon would be the rendering function
    'id' => 'nr',
    'header' => 'Nr',
    'dataIndex' => 'nr',
    'width' => 200,



    json_encode$colModel ); 
    On the client side I get the data from PHP with a This gets passed to the grid's ColumnModel:

    PHP Code:

    cm Ext.decoderesponse.responseText );

    colModel = new Ext.grid.ColumnModel(cm); 
    My problem is, that PHP's json_encode() converts the value of "renderer" to a string:
    In the column definition, however, it needs to appear WITHOUT quotes. Does anyone have an idea how this can be done?


  2. #2


    Try this:

    $json_encoded_colModel = str_replace ('"renderIcon"', 'renderIcon', json_encode( $colModel ));

  3. #3


    I got that far too... but that can't really be the point?! Isn't there a better way to do this?

  4. #4
    Sencha User
    Join Date
    Oct 2010

    Default Esto puede ser util.

    $json_encode1 = str_replace ('"[', '', json_encode($this->list));
    $json_encode = str_replace (']"', '', $json_encode1);

    $combo['combo']['renderer'] = '[function(){}]';

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts