Fatal error: Uncaught Error: Class 'jqGridRender' not found - php

One of my project I need to display records in tabular format for that purpose I am using Guriddo jqGrid PHP to display records, but I am getting error like:
"Fatal error: Uncaught Error: Class 'jqGridRender' not found....."
I am using PDO for connecting database.
Can any one help me out to overcome with this error?
Please have a look on my code:
require_once 'jqgrid/jq-config.php';
// include the jqGrid Class
require_once ABSPATH."jqgrid/php/PHPSuito/jqGrid.php";
// include the driver class
require_once ABSPATH."jqgrid/php/PHPSuito/DBdrivers/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$sql = 'select member_id,members.full_name, email, mobile, member_type, state_name, city_name, location_name, IF(status=1,"YES","NO") as status, IF(validation_success=1,"YES","NO") as validation_success, profile_picture, date_added, date_updated, last_seen, isloggedin';
$sql .= " from members ";
$grid->SelectCommand = $sql;
// Set the table to where you add the data
$grid->table = 'members';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('manage_member_grid.php');
// Set some grid options
$grid->setGridOptions(array("rowNum"=>100,"sortname"=>"full_name","sortorder"=>"asc","height"=>150,"multiselect"=>true,"hoverrows"=>true,"rowList"=>array(10,20,30,40,50,100),"shrinkToFit"=>false,"width"=>1140,"height"=>500));//
//Set Primary Key for row
$grid->setPrimaryKeyId("member_id");
// Hide fields
$grid->setColProperty("member_id", array("hidden"=>true));
//Change some property of the full_name field
$grid->setColProperty("full_name", array("label"=>array("Name")));
$grid->setColProperty("full_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
//Change some property of the email field
$grid->setColProperty("email", array("label"=>array("Email")));
$grid->setColProperty("email", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
// Change some property of the mobile field
$grid->setColProperty("mobile", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));//,"width"=>300,"lable"=>array("Added Date")
$grid->setColProperty("mobile", array("label"=>array("Mobile")));
// Change some property of the member_type field
$grid->setColProperty("member_type", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));//,"width"=>300,"lable"=>array("Added Date")
$grid->setColProperty("member_type", array("label"=>array("Member Type")));
// Change some property of the State field
$grid->setColProperty("state_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("state_name", array("label"=>array("Satate")));
// Change some property of the City field
$grid->setColProperty("city_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("city_name", array("label"=>array("City")));
// Change some property of the Address field
$grid->setColProperty("location_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("location_name", array("label"=>array("Location No")));
// Change some property of the date_added field
$grid->setColProperty("date_added", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a")));//,"lable"=>array("Added Date")
$grid->setColProperty("date_added", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("date_added", array("label"=>array("Added Date")));
$grid->setDatepicker('date_added');
$grid->setColProperty('date_added', array("editable"=>false));
// Change some property of the date_updated field
$grid->setColProperty("date_updated", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a")));
$grid->setColProperty("date_updated", array("label"=>array("Last Update")));
$grid->setColProperty('date_updated', array("editable"=>false));
// Change some property of the status field
$grid->setColProperty("status", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("status", array("label"=>array("isActive")));
// Change some property of the validation_success field
$grid->setColProperty("validation_success", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("validation_success", array("label"=>array("isEmail Validate")));
// Change some property of the profile_picture field
$grid->setColProperty("profile_picture", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("profile_picture", array("label"=>array("Profile Picture"),"formatter"=>"js:formatLinkImages"));
$grid->setColProperty('profile_picture', array("editable"=>false));
// Change some property of the last_seen field
$grid->setColProperty("last_seen", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a")));//,"lable"=>array("Added Date")
$grid->setColProperty("last_seen", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("last_seen", array("label"=>array("Last Seen")));
$grid->setDatepicker('last_seen');
$grid->setColProperty('last_seen', array("editable"=>false));
// Change some property of the isloggedin field
$grid->setColProperty("isloggedin", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));
$grid->setColProperty("isloggedin", array("label"=>array("isLoggedin Now")));
$grid->setColProperty('isloggedin', array("editable"=>false));
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array(
"stringResult"=> true,
"searchOperators"=>true
));
// We can put JS from php
$custom = <<<CUSTOM
/*function formatLinkMember(cellValue, options, rowData) {
return "<a class='button' href='#login_form' id='login_pop' onclick='getMemberDetails("+rowData.member_id+")' >"+rowData.full_name+"</a>";
//return "<input type='button' value='somevalue' onclick='some_function'\>";
}*/
function formatLinkImages(cellValue, options, rowData) {
var path = "'"+rowData.member_id+"', '"+rowData.profile_picture+"'";
return '<a class="button" href="#login_form" id="login_pop" onclick="javascript:getImagesDetails('+path+');" >'+rowData.profile_picture+'</a>';
//return "<input type='button' value='somevalue' onclick='some_function'\>";
}
CUSTOM;
// Let set the code which is executed at end
$grid->setJSCode($custom);
//add on double clicl event (This will take to the View Records)
$ondblclick = <<<DBLCLICK
function(rowId, iRow, iCol, e)
{
if(rowId)
{
// this refers to grid
$(this).jqGrid('viewGridRow',rowId,{});
}
}
DBLCLICK;
$grid->setGridEvent('ondblClickRow',$ondblclick);
// add a custom button via the build in callGridMethod
// note the js: before the function
$buttonoptions = array("#pager",
array("caption"=>"Pdf", "title"=>"Export to Pdf", "onClickButton"=>"js: function(){
jQuery('#grid').jqGrid('excelExport',{tag:'pdf', url:'manage_member_grid.php'});}"
)
);
$grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions);
// Enable navigator searching
$grid->navigator = true;
// Set which buttons should be visible
$grid->setNavOptions('navigator',array("add"=>false,"edit"=>false,"del"=>false,"view"=>true,"excel"=>true,"recreateForm"=>true));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);

It is important to know which version of Guriddo Suito PHP is used. In the latest versions (can't remember which one) autoloader class is used.
Maybe you can try to load the render class insted of jqgrid one i.e replace
// include the jqGrid Class
require_once ABSPATH."jqgrid/php/PHPSuito/jqGrid.php";
with this one
// include the jqGrid Class
require_once ABSPATH."jqgrid/php/PHPSuito/jqGridRender.php";

Related

How to properly display a calculated value of a non-db field in the ListView?

In Suitecrm/SugarCRM 6.5
I need to modify the ListView. Showing the value of a field based on a certain condition.
In the Account module, the name field may be empty based on certain conditions, I require that when this occurs show the value of a custom field. To do this, first I tryied using 'customCode' + smarty as usual in Edit/Detail vies, but in several posts mention that this is not possible in the ListView. The concession is to use logic hooks + a non-db field to store the calculated field. Following this SO answer I have written the following:
Custom field at custom/Extension/modules/Accounts/Ext/Vardefs/custom_field_name_c.php
<?php
$dictionary['Account']['fields']['name_c']['name'] = 'account_name_c';
$dictionary['Account']['fields']['name_c']['vname'] = 'LBL_ACCOUNT_NAME_C';
$dictionary['Account']['fields']['name_c']['type'] = 'varchar';
$dictionary['Account']['fields']['name_c']['len'] = '255';
$dictionary['Account']['fields']['name_c']['source'] = 'non-db';
$dictionary['Account']['fields']['name_c']['dbType'] = 'non-db';
$dictionary['Account']['fields']['name_c']['studio'] = 'visible';
Label at suitecrm/custom/Extension/modules/Accounts/Ext/Language/es_ES.account_name_c.php
<?php
$mod_strings['LBL_ACCOUNT_NAME_C'] = 'Nombre de cuenta';
Logic hook entry at custom/modules/Accounts/logic_hooks.php
$hook_array['process_record'] = Array();
$hook_array['process_record'][] = Array(
2,
'Get proper name',
'custom/modules/Accounts/hooks/ListViewLogicHook.php',
'ListViewLogicHook',
'getProperName'
);
Logic hook at custom/modules/Accounts/hooks/ListViewLogicHook.php
<?php
class ListViewLogicHook
{
public function getProperName(&$bean, $event, $arguments)
{
if (empty($bean->fetched_row['name'])) {
$bean->account_name_c = $bean->fetched_row['person_name_c'];
} else {
$bean->account_name_c = $bean->fetched_row['name'];
}
// Here I also tried, but same result
// $bean->account_name_c = empty($bean->name) ? $bean->person_name_c : $bean->name;
}
}
listviewdefs.php at custom/modules/Accounts/metadata/listviewdefs.php
I added the field
'NAME_C' =>
array (
'width' => '20%',
'label' => 'LBL_ACCOUNT_NAME_C',
'default' => true,
),
After these modifications and repair I hope to see the field full with the right value. But it appears empty. I have verified that the logic hook is properly called, but the name andperson_name_c fields are always empty. In case it is relevant I have verified in Studio that the name fields in Account is typename I do not know what this means when it comes to obtaining its value.
I appreciate your comments
The problem is in the logic hook is due to first that the $bean does not have access to the custom fields, so I have to invoke them using $bean->custom_fields->retrieve(); Also the name field is always empty, I had to use DBManager to get only the name field.
The logic of the final logic hook is the following:
<?php
class ListViewLogicHook
{
public function getProperName($bean, $event, $arguments)
{
// Get access to custom fields from $bean
$bean->custom_fields->retrieve();
// Get access to name property using DBManager because $bean->name return null
$sql = "SELECT name FROM accounts WHERE id = '{$bean->id}'";
$name = $GLOBALS['db']->getOne($sql);
// Assign a value to non-db field
$bean->name_c = empty($name) ? $bean->nombre_persona_c : $name;
}
}
I was not familiar with the method $bean->custom_fields->retrieve() and at the moment I do not know why is empty the name field and I understand others fields remain empty.
I hope this is useful
We achieved that doing an after_retrieve hook, very fast and simple - This is taken from a working example.
public function RemoveCost(&$bean, $event, $arguments)
{
global $current_user;
include_once(‘modules/ACLRoles/ACLRole.php’);
$roles = ACLRole::getUserRoleNames($current_user->id);
if(!array_search("CanSeeCostRoleName",$roles)){
$bean->cost = 0;
$bean->cost_usdollar = 0;
}
}
All you need is to define and add this function to the module logic_hooks.php
You can even tailor down to specific calls:
if (isset($_REQUEST['module'],$_REQUEST['action']) && $_REQUEST['module'] == 'Opportunities' && $_REQUEST['action'] == 'DetailView')
As some times there are views you do want to show the field, for example quicksearch popup.

Add a user with particular role, ex: admin or normal user

I am using PHP(laravel). I want to add role with each user I add.
How can I achieve it?
$postData->__set('roles',$postData->dataType('relation',array('Role','_user')));
I used something like this, but it is not proper.
I am able to save users to the user table in parse, but I have two roles in the roles table, admin and user(normal user). I need to add my user one among this. 'Relation' is a datatype in parse.com, using that is there some way to achieve it.
Just use CodeCloud and call the Cloud Function using the Parse.com PHP Library.
This function in JavaScript add an array of User's ObjectId to a role with a Name
// Add array of user ids to role with defined name
Parse.Cloud.define('addUsersToRole', function(request, response) {
// Params
var userIds = request.params.users;
var roleName = request.params.role;
// Underscore
var _ = require('underscore');
// Master Key
// skip ACL check
Parse.Cloud.useMasterKey();
// new role query
var query = new Parse.Query(Parse.Role);
// get the role with given name
query.equalTo('name', roleName);
// get the first result using promises
query.first().then(function(role){
if(role) {
var userRelation = role.relation('users');
_.each(userIds, function(userId) {
// create a new user object
var user = new Parse.User();
// assign the id
user.id = userId;
// add it to the role user relation
userRelation.add(user);
// a simple user counter
role.increment('userCount');
});
// save the role
role.save().then(function(){
response.success();
});
} else {
response.error('No Role found with Name ' + roleName);
}
});
});
Then using the PHP Parse Library call the function
<?php
// https://github.com/apotropaic/parse.com-php-library/blob/master/parseCloud.php
// Adding the possibility to run parse cloud code functions
$cloud = new parseCloud("addUsersToRole");
// Setting the params
$cloud->__set('users',array('oviajjs3', 'CskkO33d', 'Casi33Jn'));
$cloud->__set('role','admin');
// Running the cloud function
$result = $cloud->run();
?>

Make an attendance sheet with jqGrid

I want to make an attendance sheet with jqGrid. I'm using PHP and Mysql
I have two tables, one called MemberInfo and one called Attendance.
From the MemberInfo I want to show in the grid the first name and the last name of the member. Then I want to have a box for every day of the week. I want that when I add some data to those fields, for the data to be saved in the Attendance table and also that if I generate the Attendance grid again, the fields that were already filled up, to show the data.
My question is:
How can I add more columns and How can I connect those columns with the Attendance table? Thanks!
EDIT:
I was able to generate new columns and to add the data to the database with cellEdit. Still having problems with generating the grid with the data from 2 tables. Thanks!
I hope this is clear! if its not please let me know! thanks!
(if there is another library for PHP that would make this easier please let me know)
EDIT:
<?php
require_once 'jqgrid/jq-config.php';
// include the jqGrid Class
require_once "jqgrid/php/jqGrid.php";
// include the driver class
require_once "jqgrid/php/jqGridPdo.php";
// Connection to the server
$conn = new PDO("mysql:host=localhost;dbname=db;","root",NULL);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT member_id, first_name, last_name FROM members_info WHERE member_type !=5';
// set the ouput format to json
$grid->dataType = 'json';
$grid->table ="members_info";
$grid->setPrimaryKeyId("member_id");
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
$grid->cacheCount = true;
// Set grid caption using the option caption
$today = date('Y-m-d');
if(isset($_POST['past_month'])){
$today = date('Y-m-d', strtotime($_POST['past_month']));
}
if(isset($_POST['next_month'])){
$today = date('Y-m-d', strtotime($_POST['next_month']));
}
$days = attendance_cal(date('F', strtotime($today)), date('Y', strtotime($today))); // Gets the days for that month and that year
sort($days); //sort the days
foreach($days as $day){
$grid->addCol(array(
"name"=>date('m-d', $day)
));
}
$grid->setGridOptions(array(
"caption"=>"This is custom Caption",
"rowNum"=>30000,
"sortname"=>"member_id",
"hoverrows"=>true,
"width"=>1000,
"height"=>1000,
"cellEdit"=> true,
"cellsubmit"=>"remote",
"cellurl"=> "cell_dump.php",
"rowList"=>array(10,20,50),
"postData"=>array("grid_recs"=>776)
));
// Change some property of the field(s)
$grid->setColProperty("member_id", array("label"=>"ID", "width"=>60, "editable"=>false));
$grid->setColProperty("first_name", array("label"=>"First Name", "width"=>120, "editable"=>false));
$grid->setColProperty("last_name", array("label"=>"Last Name", "width"=>120, "editable"=>false));
// Enjoy
$grid->navigator = false;
// and finaly bind key navigation
// This is way if no events or parameter
//$grid->callGridMethod('#grid', 'bindKeys');
//
//in case of passing events is better this way
$bindkeys =<<<KEYS
$("#grid").jqGrid('bindKeys', {"onEnter":function( rowid ) { alert("You enter a row with id:"+rowid)} } );
KEYS;
$grid->setJSCode($bindkeys);
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
Let me be more specific:
My table "Members" has the fields "member_id", "first_name", "last_name"
The "Attendance" table has the fields "attendance_id", "member_id", "attendance_date" ,"attendance_value"
My Grid, I want it to look like:
| Member Id | Name | 03-15-2012 | 03-20-2012 | 03-22-2012 |
The "Member Id" column and "Name" column is being generated from the "Members" table with the SelectCommand, the other columns I'm creating them with addCol. I kinda can figure out how to add data to the database via cellEdit, but when I load the sheet, I dont know how to put the data from the database in the grid besides for the ones coming from the Members table. I hope this is clearer! thanks!
I am assuming you have never used jqGrid and you need to get started...
Please have a look at this link, it gives you demos with code for everything you need to know on how to create your grid using PHP.
http://www.trirand.net/demophp.aspx

Conditionally enable or disable delete record button based on the Content of the cell (not just the the id)

I am new to jquery and jqgrid, but i am comfortable with javascript. However I have managed to install jqgrid after some effort.
I have been trying a to find a solution to enable ore disable the delete feature from the navigation bar based on the value of the 'lock' column. I read the following link
jqgrid: how to set toolbar options based on column value in row selected
But I was not able to get the contents of 'lock' cell for the javascript. I also tried to format the lock string without effect.
the jqgrid is loaded via php. The script is here http://www.trirand.net/demophp.aspx
The php script is the following
require_once("JQGrid/jq-config.php");
require_once("JQGrid/php/jqGridASCII.php");
require_once("JQGrid/php/jqGridPdo.php");
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$grid = new jqGridRender($conn);
$grid->SelectCommand = 'SELECT * FROM `device_assignement` ';
$grid->dataType = 'json';
$grid->setColModel();
$grid->setUrl('Grid_ecu_display.php');
$grid->setColProperty("company",
array("label"=>"Dealer Name",
"width"=>350
),
array( "searchrules"=>
array("searchhidden"=>false, "required"=>false, "search"=>false)));
$grid->setGridOptions(array(
"sortable"=>true,
"rownumbers"=>true,
"rowNum"=>40,
"rowList"=>array(10,50,100),
"sortname"=>"ecu",
"width"=>940,
"height"=>400,
"shrinkToFit"=>true,
"hidden" => true,
"hoverrows"=>true ));
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
$grid->setColProperty("ecu", array(
"label"=>"ECU Number" ,
"sortable"=>true
));
$grid->setColProperty("lock", array(
"label"=>"<i>Lock</i>" ,
"width"=>60,
"sortable"=>false,
"editable"=>true
));
etc etc...
$ecu = jqGridUtils::GetParam('ecu');
// This command is executed immediatley after edit occur.
$grid->setAfterCrudAction('edit', "UPDATE `ecu_master` SET `lock` = '1' WHERE `ecu` =?",array($ecu));
$grid->navigator = true;
$grid->setNavOptions('navigator', array("pdf"=>true, "add"=>false,"edit"=>true,"del"=>false,"view"=>false, "excel"=>true));
$grid->setColProperty('company',array("searchoptions"=>array("sopt"=>array("cn"))));
$oper = jqGridUtils::GetParam("oper");
if($oper == "pdf") {
$grid->setPdfOptions(array(
// set the page orientation to landscape
"page_orientation"=>"L",
// enable header information
"header"=>true,
// set bigger top margin
"margin_top"=>27,
// set logo image
//"header_logo"=>"logo.gif",
// set logo image width
//"header_logo_width"=>30,
//header title
"header_title"=>"Autograde CMS ECU Allocation List",
// and a header string to print
"header_string"=>"$SoftwareVersion"
));
}
// Run the script
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
This is included in another php script where.
All I want is to enable or disable the delete row button based on the "lock" value
If this seems too basic and ridiculous please let me know I will understand.
If the user click on a cell of the grid the whole row will be selected and the callback function onSelectRow will be called. So you should implement the callback function onSelectRow which has the rowid (the id of the <tr>) as the first parameter. Inside of the onSelectRow handler you can call getCell method. Depend on the value of the 'lock' column (which can be hidden if needed) you can enable of disable "Edit" and "Delete" buttons of the navigator bar.
So the code can be about the following:
$('#list').jqGrid({
... all other jqGrid options which you need
pager: '#pager',
onSelectRow: function (rowid) {
var gridId = $.jgrid.jqID(this.id);
// test 'lock' column for some value like 'yes'
if ($(this).jqGrid('getCell', rowid, 'lock') === 'yes') {
// disable the "Edit" and "Delete" buttons of the navigator
$("#edit_" + gridId).addClass('ui-state-disabled');
$("#del_" + gridId).addClass('ui-state-disabled');
} else {
// enable the "Edit" and "Delete" buttons of the navigator
$("#edit_" + gridId).removeClass('ui-state-disabled');
$("#del_" + gridId).removeClass('ui-state-disabled');
}
}
}).jqGrid('navGrid', '#pager');
Because you are new in jqGrid I want comment the usage of $.jgrid.jqID() function. In the most cases if returns the value of the input parameter: 'list' in case of the example. It's needed for more common case if the id of the grid (the id of the <table> element) contains meta-characters. $.jgrid.jqID() function include additional escape characters (two backslashes: \\) before any meta-character.

set column names my own in jqgrid

I would like to add my own column names in jqgrid and also i want to prevent the column names that is automatically added by jqgrid according to sql query.
I am using this code to do that, but its also getting the name of columns which i have not declare in the method $grid->setColModel(null, null, $mylabels);
Can anyone please tell me what code i should to write for removing extra added column in jqgrid.
require_once '/var/www/html/zbajtmp/public/jqgrid/jq-config.php';
// include the jqGrid Class
require_once "/var/www/html/zbajtmp/public/jqgrid/php/jqGrid.php";
// include the driver class
require_once "/var/www/html/zbajtmp/public/jqgrid/php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
//$grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders';
$grid->SelectCommand = 'SELECT * FROM clinic';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
//$grid->setColModel();
$mylabels = array(
"clinic_name"=>"Clinic ame",
"clinic_address"=>"Address",
"HomePhone"=>"Home Phone",
"WorkPhone"=>"Work Phone",
"Email_Id"=>"Email",
);
// Let the grid create the model with the desired labels
$grid->setColModel(null, null, $mylabels);
// Set the url from where we obtain the data
//$grid->setUrl('/var/www/html/zbajtmp/application/views/scripts/clinic/grid.php');
$grid->setUrl('http://sunlinux/zbajtmp/application/views/scripts/clinic/grid.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
"caption"=>"This is my custom Caption...",
"rowNum"=>50,
"sortname"=>"id",
"hoverrows"=>true,
"rowList"=>array(20,50,100,1000),
"width"=>"100%",
"height"=>350,
"footerrow"=>true,
"rownumbers"=>true,
"multiselect"=>true,
"altRows"=>true,
"altclass"=>'clsalt',
"loadtext"=>"<div class='loadingbox'>Please wait. Loading...</div>",
));
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
Thanks a lot.
You need to explicitly select the columns you want - SELECT * wont work
So you need to change :
$grid->SelectCommand = 'SELECT * FROM clinic';
to
$grid->SelectCommand = 'SELECT clinic_name,clinic_address,HomePhone,WorkPhone,Email_Id FROM clinic';

Categories