Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2005
    Messaggi
    2,125

    JqGrid - formattare colonna in Euro

    Ciao a tutti.

    Non riesco a capire come possa formattare le colonne della mia Grid.

    Prelevo i dati da database, quindi il mio codice e' il seguente :
    Codice PHP:

    // Create the jqGrid instance
    $grid = new jqGridRender($conn);
    // Data from this SQL is 1252 encoded, so we need to tell the grid
    // Set the SQL Data source
    $pt_id =  $_SESSION["myPath"];

    if(!isset(
    $pt_id)){
    $pt_id jqGridUtils::GetParam("pt_id");
    }

    $grid->SelectCommand ='SELECT Id,codice,descrizione,prezzo,ownerEl,slave,treePath FROM tree_elements WHERE treePath LIKE "'.$pt_id.'%" AND slave=1';
    //$grid->SelectCommand ='SELECT Id,codice,descrizione,prezzo,ownerEl FROM tree_elements WHERE ownerEl = ? ';

    $grid->setGridOptions(array("postData"=>array("pt_id"=>$pt_id)));

    $grid->setColModel(null, array($pt_id));



    // set the ouput format to XML
    $grid->dataType 'json';

    $grid->renderGrid("#grid","#pager"truenull, array($pt_id),truetrue);
    $conn null

    Quello che non capisco.... in che modo posso mantenere il contenuto delle celle prelevato da Db e formattare la colonna come il tipo di dato presente sul db?

    O cmq mi basterebbe cambiare solo 1 colonna.


    Ho provato con il Model ma io gia usavo la funzione setModel passando il mio parametro variabile....

    Codice PHP:

    $Model 
    = array(
        array(
    "name"=>"Integer","width"=>80,
            
    "formatter"=>"integer",
            
    "formatoptions"=>array("thousandsSeparator"=>","), "sorttype"=>"integer"),
        array(
    "name"=>"Number","width"=>80,
            
    "formatter"=>"number""formatoptions"=>array("decimalPlaces"=>1), "sorttype"=>"number"),
        array(
    "name"=>"Currency","width"=>80,
            
    "formatter"=>"currency",
            
    "formatoptions"=>array("decimalPlaces"=>1,"thousandsSeparator"=>",","prefix"=>"$","suffix"=>" USD"), "sorttype"=>"currency"),
        array(
    "name"=>"Email","width"=>120,"formatter"=>"email"),
        array(
    "name"=>"Link","width"=>120,"formatter"=>"link"),
        array(
    "name"=>"Checkbox","width"=>50,"formatter"=>"checkbox")
    );
    // Let the grid create the model
    $grid->setColModel($Model); 

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2005
    Messaggi
    2,125
    trovato .

    Codice PHP:
    $grid->setColProperty("prezzo", array(
        
    "formatter"=>"currency",
        
    "formatoptions"=>array("decimalPlaces"=>2,"thousandsSeparator"=>",","prefix"=>"€ ","suffix"=>""),
        
    "search"=>false
        
    )
    ); 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.