subgrid-subgrid_detail the subgrid_detail shoes always the last from subgrid

Questionssubgrid-subgrid_detail the subgrid_detail shoes always the last from subgrid
Gerd asked 8 years ago

Hallo,

when i click on the +-sign on a row in the grid, i see in the subgrid_detail always the details from the last row in subgrid.

do you have an idee ?

Here are my code

$PHPGRIDSFolder = $_SESSION["pfad"]."phpgrid";
include_once($PHPGRIDSFolder."/config.php");

// include and create object
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");

$db_conf = array();
$db_conf["type"] = PHPGRID_DBTYPE;
$db_conf["server"] = PHPGRID_DBHOST; // or you mysql ip
$db_conf["user"] = PHPGRID_DBUSER; // username
$db_conf["password"] = PHPGRID_DBPASS; // password
$db_conf["database"] = PHPGRID_DBNAME; // database

# PHPGRID2 Start———————————————–
// pass connection array to jqgrid()
$grid = new jqgrid($db_conf);

$opt = array();
$opt["caption"] = "Voting-Spieler-Anzahl: " ; // caption of grid
$opt["height"] = "";
$opt["rowNum"] = "5";

# subgrid STart———————————————–
// following params will enable subgrid — by default 'rowid' (PK) of parent is passed
$opt["subGrid"] = true;
$opt["subgridurl"] = "E03_VotingStatistik_Spieler_subgrid.php";

// call some JS on subgrid load
// $opt["subGridRowExpanded"] = "function(){ setTimeout(function(){ alert('connect ckeditor code'); },200); }";

$opt["subgridparams"] = "id_spieler1,id_voting"; // comma sep. fields. will be POSTED from parent grid to subgrid, can be fetching using $_POST in subgrid

# subgrid Ende———————————————–

$grid->set_options($opt);

$sql = "
Select
Concat(hhc_s_spieler.DT_Name, ', ', hhc_s_spieler.DT_Vorname) As Fullname,
Sum(Case When hhc_voting_details.dt_auswahl_titel = '0' Then 1 Else 0 End) As vote_nein,
Sum(Case When hhc_voting_details.dt_auswahl_titel = '1' Then 1 Else 0 End) As vote_ja,
count(*) As total,
hhc_voting.id_voting,
hhc_voting_details.fk_hhc_s_spieler_id_spieler As id_spieler1,
hhc_voting.dt_voting_anzahl
From
hhc_voting_details Inner Join
hhc_voting
On hhc_voting.id_voting = hhc_voting_details.fk_hhc_voting_id_voting Inner Join
hhc_s_spieler
On hhc_voting_details.fk_hhc_s_spieler_id_spieler = hhc_s_spieler.ID_Spieler
Where
hhc_voting.id_voting = ".$_GET["id_voting"]. "
Group By
Concat(hhc_s_spieler.DT_Name, ', ', hhc_s_spieler.DT_Vorname), hhc_voting_details.fk_hhc_s_spieler_id_spieler,
hhc_voting.dt_voting_anzahl";

$grid->select_command = $sql;

// this db table will be used for add,edit,delete
$grid->table = "hhc_voting_details";

$col1 = array();
$col1["title"] = "id_voting"; // caption of column, can use HTML tags too
$col1["name"] = "id_voting"; // grid column name, same as db field or alias from sql
#$col["width"] = "10"; // width on grid
$col1["editable"] = false;
$col1["hidden"] = true;
$col1["export"] = false; // this column will not be exported
$cols1[] = $col1;

$col1 = array();
$col1["title"] = "Name"; // caption of column, can use HTML tags too
$col1["name"] = "Fullname"; // grid column name, same as db field or alias from sql
$col1["width"] = "130"; // width on grid
$col1["editable"] = false;
$col1["sortable"] = true;
$cols1[] = $col1;

$col1 = array();
$col1["title"] = "id_spieler1"; // caption of column, can use HTML tags too
$col1["name"] = "id_spieler1"; // grid column name, same as db field or alias from sql
#$col["width"] = "10"; // width on grid
$col1["editable"] = false;
$col1["hidden"] = false;
$cols1[] = $col1;

// pass the cooked columns to grid
$grid->set_columns($cols1);

$grid->set_actions(array(
"add"=>true, // allow/disallow add
"edit"=>true, // allow/disallow edit
"delete"=>true, // allow/disallow delete
"rowactions"=>true, // show/hide row wise edit/del/save option
"search" => "advance", // show single/multi field search condition (e.g. simple or advance)
"showhidecolumns" => false
)
);

// render grid and get html/js output
$out = $grid->render("list1");

Regards Gerd

2 Answers
Abu Ghufran answered 8 years ago

Hi,

I am unable to fin any such issue in code.
If you can send screenshot + code/sample db … i'll try to regenerate.

You can email me at [email protected]

Gerd answered 8 years ago

Hallo Abu,

thank your for answering.

i have found my error. The first cplumn in the grid ("id_voting") is not unique. i have change the order with the unique ID("id_spieler1") and it works.

Your Answer

1 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?