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_Related Related Topics sp_TopicIcon
Master Detail Add data ok Problems with Edit and delete.
07/03/2013
12:06
Avatar
leerickx
brussels
Member
Members
Forum Posts: 9
Member Since:
18/02/2013
sp_UserOfflineSmall Offline

Hello everybody and first of all,

I would like to thank all the people like Tony or Oleg with their various codes below that really help me.

I've a Grid (table 'fiche') with sub Grid (data from 'fiche) and Grid Detail who display correctly my data from another table 'fileupload' (FK index)

ficheprojet.jqGrid({    

//=============    

// Grid Setup

url:'jqgrid.php?q=2',

datatype: 'xml',

mtype: 'GET',

pager: '#gridpager',

editurl: "addupdatedeldata.php",

//=============    

// subGrid Setup

subGrid : true,

subGridUrl: 'subgrid.php?q=2',   

subGridModel: [{ name  : ['nomactivite'], width : [400] },

//=============    

// onSelectRow Master Detail

onSelectRow: function(ids) {

if(ids == null) {

ids=0;

if(jQuery("#list10_d").jqGrid('getGridParam','records') >0 )

{

jQuery("#list10_d").jqGrid('setGridParam',{url:"subgridupload.php?q=2&id="+ids,page:1}); jQuery("#list10_d").jqGrid('setCaption',"Fiche Projet ID: "+ids) .trigger('reloadGrid');

}

} else {

jQuery("#list10_d").jqGrid('setGridParam',{url:"subgridupload.php?q=2&id="+ids,page:1}); jQuery("#list10_d").jqGrid('setCaption',"Fiche Projet ID: "+ids) .trigger('reloadGrid');

}

},

//=============    

// Column Definition

colNames:['id', 'secteur', 'projet', 'datec', 'datef','educperm', 'nomactivite', 'actionreguliere', 'animateur', 'collaboration', 'lieu', 'nbreparticipant','dureeanim', 'objgen', 'objop', 'prerequis'],

colModel :[  

{name:'id', index:'id', fixed:true, width:30},

{name:'idsecteur', index:'secteur', width:30, search:true, editable:true, edittype:"select"},

{},

{name:'prerequis', index:'prerequis', width:300, editable:true,hidden:true, editrules: {edithidden: true}, edittype:"textarea",}    

],

});

$("#ficheprojet").jqGrid('navGrid','#gridpager',{edit:true,add:true,del:true,search:true}, 

{//prmEdit

closeAfterEdit:true,

viewPagerButtons:false,

recreateForm:true,

},

{//prmAdd

closeAfterAdd:true}

);

// DETAIL Setup I test how to add/edit/del into another table before going further)

jQuery("#list10_d").jqGrid({

height: 200,

width: 700,

url:'subgridupload.php?q=2&id=0',

//editurl: "addupdatedeldataFileUpload.php",

datatype: "xml",

mtype: 'GET',

colNames:['idfileupload','namefileupload','id'], //'id' come from Master from my table 'ficheprojet' now I try just to understand and this not really an uploadfile, I insert a name to test the insert in my table 'fileupload' and display in the detail.

colModel:[

{name:'idfileupload', index:'idfileupload', fixed:true, width:30},

{name:'namefileupload', index:'namefileupload', width:55, editable:true },

{name:'id', index:'id', fixed:true, width:30 },

],

rowNum:20,

rowList:[5,10,20],

rownumbers: true,

viewrecords: true,

pager: '#pager10_d',

multiselect: false,

caption:"Upload"

}).navGrid('#pager10_d',{add:true,edit:true,del:true}, //options

{//prmEdit

reloadAfterSubmit:false,

closeAfterEdit:true,

viewPagerButtons:false,

recreateForm:true,

},

{//prmAdd

closeAfterAdd:true,

beforeShowForm: function(formid) {

// we should get the id of the master here

var mid = jQuery("#ficheprojet").getGridParam('selrow');

if (mid != null ) {

// now we can set it in editurl

jQuery("#list10_d").setGridParam({editurl:'addupdatedeldataFileUpload.php?q=2&id=0'+mid}); //everything works fine

}

else alert("Vous n'avez sélectionné aucune fiche")

}

},

{//prmDel

closeAfterDel:true,

reloadAfterSubmit:false,

}

);

});

I post my addupdatedeldataFileUpload.php

<?php

include_once('dbconfig.php');

$idfileupload = $_POST['idfileupload'];

$namefileupload = $_POST['namefileupload'];

$id = $_GET['id'];

if ($_POST['oper'] == 'add') {

$q = mysql_query("insert into fileupload (namefileupload, id) VALUES('$_POST[namefileupload]','$_GET[id]')") or die(mysql_error());

}

if ($_POST['oper'] == 'edit') {

$q = mysql_query("update fileupload set namefileupload='$namefileupload', id='$id' where idfileupload='$idfileupload'")or die(mysql_error());

}

if ($_POST['oper'] == 'del') {

$q = mysql_query("delete from fileupload where idfileupload='$idfileupload'")or die(mysql_error());

}

?>

I do not understand why insert data works fine in a row and into the table fileupload , the data is displayed too correctly, but I can neither deleter nor updater data from my table 'fileupload'.

When I delete a row in Detail Grid i see the row deleted but not in my table and if i reload the detail grid my row is always there.

When I updated the row I've the same problem but one more with the master id who change in my row. There is not the same.

A very big thank you for helping me.

08/03/2013
15:48
Avatar
leerickx
brussels
Member
Members
Forum Posts: 9
Member Since:
18/02/2013
sp_UserOfflineSmall Offline

well,

I tried to put in the parameter of Edit :

beforeShowForm: function(fordid) {

var mygriddetail = $('#list10_d');

var did = mygrid.jqGrid('getGridParam','selrow');

var celdid = mygrid.jqGrid('getCell', did, 'id');

if (did != null) {

jQuery("#list10_d").setGridParam({editurl:'addupdatedeldataFileUpload.php?q=2&id='+celdid});

}

else alert("Vous n'avez sélectionnez aucune fiche")

}

..... nothing to do, the update doesn't work.....

11/03/2013
16:45
Avatar
leerickx
brussels
Member
Members
Forum Posts: 9
Member Since:
18/02/2013
sp_UserOfflineSmall Offline

Cool

Sorry I had some trouble with my db...
I delete the relation between my two tables and success.
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
66 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