
Originally Posted by
bgil
I think we need more information. It sounds like a user signs on, and the server returns a 1, 5, or 9 - I would guess in JSON format. Can you show the code where that number is returned and into what variable it is placed?
Well, yes : a script (UsersController.php called from a SigmaGrid JS file) returns values for the user from a DB table :
PHP Code:
$json=json_decode(stripslashes($_POST["_gt_json"]));
if($json->{'action'} == 'load'){
$sql = "SELECT * FROM users";
$handle = mysql_query($sql);
$retArray = array();
while ($row = mysql_fetch_object($handle)) {
$retArray[] = $row;
}
$data = json_encode($retArray);
$ret = "{data:" . $data .",\n";
$ret .= "recordType : 'object'}";
echo $ret;
}
and here's the java code which calls the script above :
Code:
var grid_demo_id = "myGrid1";
var dsOption= {
fields :[
{name : 'username' },
{name : 'full_name' },
{name : 'userlevel' },
{name : 'email' },
{name : 'phone' }
],
recordType : 'object'
}
var colsOption = [
{id: 'username' , header: "Username" , width :80 },
{id: 'full_name' , header: "Full Name" , width :150 , editor:{type:'text'}},
{id: 'userlevel' , header: "Userlevel" , width :70, width :80 , editor : { type :"text" }},
{id: 'email' , header: "Email" , width :150, width :160 , editor : { type :"text" }},
{id: 'phone' , header: "Phone" , width :70, width :80 , editor : { type :"text" }}
];
var gridOption={
id : grid_demo_id,
loadURL : '/grid/UsersController.php',
saveURL : '/grid/UsersController.php',
width: "700", //"100%", // 700,
height: "200", //"100%", // 330,
container : 'gridbox',
replaceContainer : true,
encoding : 'UTF-8', // Sigma.$encoding(),
dataset : dsOption ,
columns : colsOption ,
clickStartEdit : true ,
defaultRecord : {'full_name':"",'userlevel':"",'email':"",'phone':""},
pageSize:100,
toolbarContent : 'reload | del | save | print'
};
var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad(function(){mygrid.render()});
The values for the column userlevel are 1, 5 or 9 but I don't want to display NUMBERS, but guest, member and admin respectively... That's where I need your help guys 
Thank you in advance!
Bookmarks