Forum


11:58

01/04/2010

Hi,
I'm using php and a mysql db to manage user login in my website.
For now, just administrators can login in the website, so in PHP i can check if they are logged in using:
if($session->logged_in){
}
I'm using the file mycustom.js to load create the jqgrid like this:
jQuery(document).ready(function(){
jQuery("#griglia-negozi").jqGrid('navGrid','#pager-griglia-negozi', {refresh: true, edit: false, add: false, del: false,
search:false},{},{},{},{multipleSearch:true, closeAfterSearch: true, closeOnEscape: true},{});
);
the problem is that I would like the grid to be editable if a user is logged in, but I don't know how to integrate a php "if clause" in the file mycustom.js to achieve something like:
<?php
if($session->logged_in){
?>
jQuery(document).ready(function(){
jQuery("#griglia-negozi").jqGrid('navGrid','#pager-griglia-negozi', {refresh: true, edit: false, add: false, del: false,
search:false},{},{},{},{multipleSearch:true, closeAfterSearch: true, closeOnEscape: true},{});
);
<?php
} else
{
?>
jQuery(document).ready(function(){
jQuery("#griglia-negozi").jqGrid('navGrid','#pager-griglia-negozi', {refresh: true, edit: true, add: true, del: true,
search:true},{},{},{},{multipleSearch:true, closeAfterSearch: true, closeOnEscape: true},{});
);
<?php
}
?>
Could you help me?
thank you,
Lorenzo
13:31

Moderators
30/10/2007

Hello,
I do not think it is a jqGrid problem. Just a opinion
Maybe you will need to define somethings like this
$grid1 = <<<GRID1
here first code
GRID1
$grid2 = <<<GRID2
here second code
GRID2;
And the echo the $grid1 and $grid2 depending on conditions
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.
13:46

01/04/2010

Hi Tony,
thank you for answering. No, it's not a jqgrid problem, the grid works perfectly.It's just that I am not able to change the possibility to edit/insert/delete records AFTER the grid creation.
So you are saying I should create 2 grids identical, one which I can edit and the other locked and then decide which one to show depending if the user is logged or not?
Isn't there a way to link to the grid from php and just change the property of the grid?
Sorry if the question is stupid, I'm very new in web programming. It would be great if you could provide me with a couple of detailed lines..I can't find any example anywhere..
btw, thank you so much for this great grid!
Thank you so much,
Lorenzo
Most Users Ever Online: 715
Currently Online:
111 Guest(s)
Currently Browsing this Page:
1 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