Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Cant edit records in a grid using SQL server 2005
10/09/2011
00:32
Avatar
eradom78
new york
New Member
Members
Forum Posts: 1
Member Since:
10/09/2011
sp_UserOfflineSmall Offline

I can't seem to be able to edit records in my grid.  My sql connection works fine and I get data in the grid however, editing does not work at all.  For some reason my primary key is being posted as a sequential number of a record in my grid instead of actual field.

Also my table has two primary keys how would that work?

What am I doing wrong here?Frown

here is my code.

//require_once 'jq-config.php';
// include the jqGrid Class

require_once "php/jqGrid.php";
require_once "php/jqGridSqlsrv.php";

// include the PDO driver class

$connectionInfo = array("Database"=>"CDO_master_res","CharacterSet" => "utf-8","ReturnDatesAsStrings" => true);
$serverName = "NYSQL1";
$conn = sqlsrv_connect( $serverName, $connectionInfo);
// Create the jqGrid instance
$grid = new jqGridRender($conn);

$grid->debug = true;
// Write the SQL Query castselect cast(checkid as varchar(5))+'_'+cast(updateid as varchar(6))as pkid,
$grid->SelectCommand = "select checkid , updateid , pass , threshold , detail , CONVERT(nvarchar(20), update_date, 101) as update_date , duration, notes from qa_checks_results_pre";
// set the ouput format to json
$grid->dataType = 'json';
$grid->table = 'dbo.qa_checks_results_pre';
$grid->setPrimaryKeyId('checkid');
$grid->serialKey = false;

// Let the grid create the model

$Model = array(
            array("name"=>"checkid", "label"=>"checkid", "width"=>20, "align"=>"right","editable"=>false),//, "editable"=>false
            array("name"=>"updateid",  "label"=>"updateid", "width"=>100,"editable"=>false),
            array("name"=>"pass", "label"=>"pass", "width"=>100),
            array("name"=>"threshold", "label"=>"threshold", "width"=>150,"editable"=>false),
            array("name"=>"detail", "detail"=>"tested", "width"=>250,"editable"=>false),
            array("name"=>"update_date", "label"=>"update_date", "width"=>150,"editable"=>false),
            array("name"=>"duration", "label"=>"duration", "width"=>150,"editable"=>false),
            array("name"=>"notes", "label"=>"notes", "width"=>300)
);

$grid->setColModel($Model );
// Set the url from where we obtain the data
$grid->addCol(array(
    "name"=>"actions",
    "formatter"=>"actions",
    "editable"=>false,
    "sortable"=>false,
    "resizable"=>false,
    "fixed"=>true,
   "width"=>60,
   "formatoptions"=>array("keys"=>true)
    ), "first");
$grid->setUrl('myfirstgrid.php');
// Set grid caption using the option caption
// Enable navigator
$grid->setColProperty('checkid', array("editrules"=>array("required"=>true)));
$grid->setColProperty('updateid', array("editrules"=>array("required"=>true)));

$grid->navigator = true;
$grid->setNavOptions('navigator', array("excel"=>true,"add"=>true,"edit"=>true,"del"=>true,"view"=>true));
$grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Edit QA Results","bSubmit"=>"Submit"));
$grid->setGridOptions(array(
    "caption"=>"QA MACRO",
    "rowNum"=>20,
    "sortname"=>"updateid",
    "hoverrows"=>true,
    "height"=>"auto",
    "width"=>900,
    "rowList"=>array(20,40,60)
    ));
// Change some property of the field(s)
//$pkid = jqGridUtils::GetParam('pkid');
//$checkid = jqGridUtils::GetParam('checkid');
//$updateid= jqGridUtils::GetParam('updateid');
//$notes = jqGridUtils::GetParam('notes');
//$pass= jqGridUtils::GetParam('pass');

//if ($_SESSION['updateid']){
//$sql = "UPDATE qa_checks_results_pre SET pass ='". $pass ."',notes = '".$notes."' where cast(checkid as varchar(5))+'_'+cast(updateid as varchar(6))".$pkid.";" ;
//$_SESSION['sql'] = $sql ;
//$grid->setAfterCrudAction('edit',"UPDATE qa_checks_results_pre SET pass ='". $pass ."',notes = '".$notes."' where cast(checkid as varchar(5))+'_'+cast(updateid as varchar(6))=".$pkid.";" );
//}
////"UPDATE qa_checks_results_pre SET pass =?, notes = ? where updateid=? and checkid =?;",array($pass, $notes, $updateid, $checkid  )

$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;

10/09/2011
08:39
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

It seems you use the commertial PHP jqGrid.

Please post your problem here:

http://www.trirand.net/forum/

Regards

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
34 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information