Forum


11:54

Moderators
30/10/2007

There are a couple of ways depending on what you want to do.
Declare two variables - one for colNames the other for colModel -
on the server construct these arrays and pass them before constructing the grid.
Also you can construct the whole page with PHP and etc.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
01:29

Moderators
30/10/2007

Currently this is not possible. If you need some simple you can use hidden columns and the hideCol and showCol methods
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
03:02

19/08/2008

Ok I found a sollution. It wasn't that difficult and just to let you all know it does work.
The php end:
function test(){
$test->colnames = array('Id','Rights', 'Username', 'Password', 'First Name', 'Last Name', 'E-Mail');
$test->colmodel = array("{name:'id',index:'id', editable:false,editoptions:{readonly:true,size:10}}",
"{name:'role_id',index:'role_id', editable:true,editoptions:{size:25}}",
"{name:'username',index:'username', editable:true,editoptions:{size:25}}",
"{name:'password',index:'password', editable:true,editoptions:{size:25}}",
"{name:'first_name',index:'first_name', editable:true,editoptions:{size:25}}",
"{name:'last_name',index:'last_name', editable:true,editoptions:{size:25}}",
"{name:'email',index:'email', editable:true,editoptions:{size:25}}");
echo json_encode($test);
}
The javascript end:
$.ajax({
url: basedir+"users/test",
dataType: 'json',
success: function(data){
var colnames = data.colnames;
var colmodel = data.colmodel;
$("#usergrid").jqGrid({
url: 'path',
datatype: "json",
colNames: colnames,
colModel: colmodel,
.....
});
}
});
So you can create the full colModel en colNames in the backend, then call it through ajax and then build the grid wih that data.
I hope this is helpfull to anyone.
Kind Regards,
Karel-Jan
03:18

19/08/2008

Just one more adjustment for the colModel in the php end.
$test->colmodel = array(array('name' => 'id', 'index' => 'id', 'editable' => false , 'editoptions' => array('readonly' => true,'size' => 10)),
array('name' => 'role_id', 'index' => 'role_id', 'editable' => true,'editoptions' => array('size' => 25)),
array('name' => 'username', 'index' => 'username', 'editable' => true,'editoptions' => array('size' => 25)),
array('name' => 'password', 'index' => 'password', 'editable' => true,'editoptions' => array('size' => 25)),
array('name' => 'first_name', 'index' => 'first_name','editable' => true,'editoptions' => array('size' => 25)),
array('name' => 'last_name', 'index' => 'last_name', 'editable' => true,'editoptions' => array('size' => 25)),
array('name' => 'email', 'index' => 'email', 'editable' => true,'editoptions' => array('size' => 25)));
This works fine.
Karel-Jan
08:46

Moderators
30/10/2007

Great,
Thanks. Also we can use GridUnload method and then create again the
grid with new colModel options
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
75 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66