jqGrid : "All in One" approach width jqGridEdit Class > how to set a composite primary key ?

Posted by Qualliarys on Stack Overflow See other posts from Stack Overflow or by Qualliarys
Published on 2010-06-17T16:00:03Z Indexed on 2010/06/17 16:03 UTC
Read the original article Hit count: 332

Filed under:

Hello,

How to set a composite primary key for a "All in One" approach (grid defined in JS file, and data using jqGridEdit Class in php file) ? Please, for me a composite primary key of a table T, is a elementary primary key that is defined with some fields belong to this table T !

Here is my test, but i get no data and cannot use the CRUD operations :

  • In my JS file i have this lines code:

    ...
    colModel":[
       {"name":"index","index":"index","label":"index"}, // <= THAT'S JUST THE INDEX OF MY TABLE         
       {"name":"user","index":"user","label":"user","key":true}, // <= A PART OF MY COMPOSITE PRIMARY KEY
       {"name":"pwd","index":"pwd","label":"pwd","key":true},    // <= A PART OF MY COMPOSITE PRIMARY KEY
       {"name":"state","index":"state","label":"state","key":true}, // <= A PART OF MY COMPOSITE PRIMARY KEY
       ... <= AND SO ON
       "url":"mygrid_crud.php",
       "datatype":"json",
       "jsonReader":{repeatitems:false},
       "editurl": "mygrid_crud.php",
       "prmNames":{"id":"index"} // <= WHAT I NEED TO WRITE HERE ???
      ...
    
  • In my php file (mygrid_crud.php) :

    ...
    $grid = new jqGridEdit($conn);
    $query = "SELECT * FROM mytable WHERE user='$user' and pwd='$pwd' and state='$state'..."; // <= SELECT * it's ok or i need to specify all fields i need ? 
    $grid->SelectCommand = $query;
    $grid->dataType = "json";
    $grid->table = 'mytable';
    $grid->setPrimaryKeyId('index'); // <= WHAT I NEED TO WRITE HERE ???
    ...
    $grid->editGrid();
    

Please, say me what is wrong, and how to do to set a composite primary key in this approach !?

Thank you so much for tour responses.

© Stack Overflow or respective owner

Related posts about jqgrid