Dear Sam,
Thank you very much for the instructions and the support. I am using yii framework. This is what I did so far;
- Populate the ‘Student’ Grid and pass student_id
View Code:
<script type="text/javascript" charset="utf-8">
mygrid = new dhtmlXGridObject('student');
mygrid.setImagePath("../../../dhtmlx/grid/imgs/");
mygrid.setSkin("dhx_skyblue");
mygrid.setHeader("Name,Address");
mygrid.attachEvent("onRowSelect", function(rID,cInd){
mygrid2.clearAll();
mygrid2.load("./grid_subject?id="+rID);
})
mygrid.loadXML("./grid_student");
mygrid.init();
var mydp = new dataProcessor ("./grid_student");
mydp.init(mygrid);
</script>
- Populate a grid containing student_id , subject_id and check boxes to select. This grid linked to the student grid. And the insert function as you suggested.
View code:
<script type="text/javascript" charset="utf-8">
mygrid2 = new dhtmlXGridObject('allocation');
mygrid2.setImagePath("../../../dhtmlx/grid/imgs/");
mygrid2.setSkin("dhx_skyblue");
mygrid2.setHeader("Select,Student,Subject,Name");
mygrid2.enableMultiselect(true);
mygrid2.setColTypes("ch,ro,ro,ro");
mygrid2.loadXML("./grid_subject");
mygrid2.init();
myDataProcessor = new dataProcessor("./grid_allocation");
myDataProcessor.setTransactionMode("POST",true);
myDataProcessor.setUpdateMode("on");
myDataProcessor.init(mygrid2);
function allocate() {
myDataProcessor.sendData();
return true;
}
</script>
Data processor for grid_subject:
public function actionGrid_Subject() {
include(dirname(__FILE__) . "/../../../dhtmlx/config.php");
$res = mysql_connect("$host", "$user", "$password");
mysql_select_db("$dbname");
$id = mysql_real_escape_string($_GET['id']);
$grid = new GridConnector($res, "MySQL");
$grid->render_sql("select s1.id as student_id, s.id as subject_id,s.name as subject_name from ( select id,name from subject) as s
join (select id from student) as s1 where s1.id='" . $id . "'
", "", "'',student_id,subject_id,subject_name");
}
Data processor for insert selected student_ids and subject_ids;
public function actionGrid_allocation() {
include(dirname(__FILE__) . "/../../../dhtmlx/config.php");
$res = mysql_connect("$host", "$user", "$password");
mysql_select_db("$dbname");
$grid = new GridConnector($res, "MySQL");
$grid->render_table("subject_allocation", "id", "student_id,subject_id");
}
Both student and subject grid are work well. When I checked the row with student_id=6 and subject_id = 1, and press allocate button ‘fire bug’ say it’s updated but my database was not updated.
Here are the fire bug outputs;
response
<?xml version='1.0' ?>
Post
1352414412x0_!nativeeditor_status=updated
1352414412x0_c0=1
1352414412x0_c1=6
1352414412x0_c2=1
1352414412x0_c3=Maths
1352414412x0_gr_id=1352414412x0
ids=1352414412x0
What I did wrong here? How can I make my database updated?
Thanks for your inputs and support.