Forum


Hi,
I am using Master Detail grid. I have a column in the detail grid that is a foreign key to the primary key of the master grid.
eg. i have id in banks table. & banks_id in the accounts table.
Now I need to add a record in the detail table of accounts ( master grid conatins banks). But to add a record uder the currently selected bank I need to retrieve the current selected bank's id as I have to insert the row with the id of the bank selected in column banks_id.
How to get the id bank(master) selected in details grid(detail).
Pls help. Thanks.
03:00

Moderators
30/10/2007

if "master" is the id for the table you can do
$("master").getGridParam("selrow"); to get the selected id row of the master
Regards
Tony
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.
I am trying to pass parameter of master grid id in the navigator of detail grid.
So when I click on the add icon of navigator of detail grid & save a row it should call the below URL passing the parameter in the url (ie. id of master grid)
url: '/test/public/account/addaccount?bankID='+jQuery("#list").getGridParam("selrow")
But instead the value is null. ie. the url is always /test/public/account/addaccount?bankID=null that is being called.
Please help. Am I trying the right thing.
11:44

Moderators
30/10/2007

If you use 3.1 veresion please switch to 3.2rc. There is a bug when setting the url dynamically. You should do something like this.
Select the master id. After the master id is selected change the editurl of the detail to appropriate way.
Regards
Tony
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.
02:00

Moderators
30/10/2007

Mayank,
setUrl does not exist in 3.2 there are replacement methods for this.
Refer to Documantation how to upgrade
Regards
Tony
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.
My edit function in inline editing seems to work fine.
But I need to add a row when I click on the add record icon on the
navgrid. that is when I dont get the master id of the parent grid to pass.
here is the code for the navgrid of details grid :
jQuery("#list10_d").navGrid('#pager10_d', {}, //options
{height:180,width:400,reloadAfterSubmit:false, modal:true,
editCaption: 'Edit Account Details',
bSubmit: 'Save',
closeAfterEdit : true
}, // edit options
{height:180,width:400,reloadAfterSubmit:false, modal:true,
url: '/test/public/account/addaccount?bankID='+bankID+'',
bSubmit: 'Save',
addCaption: 'Add Account',
closeAfterAdd : true
}, // add options
{url: '/test/public/account/deleteaccount'}, // del options
{} // search options
);
Now bankID is the id i store the parent id in, when I select a row in the parent grid.
But somehow the bankID alwasy come out to be 0 ie. the initial value I have given it.
I am assigning the value of bank ID to id when onselectrow is called.
All I want to do is simply add a row in the detail grid having bankID stored in the database equal to the id of the parent grid. So that the account is
linked to that bank (accounts are shown in the detail grid). But I am not
able to pass the parent grid id through the navgrid add option to the php script.
03:13

Moderators
30/10/2007

Search this forum with word "master" and you can find the solution
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.
I checkd out all the results for "master" in your forum.
even thgis one http://www.trirand.com/blog/?p.....8;search=1
But sadly enough, I have not found the solution for implementing it
in the navgrid. I am using navgrid & my navgrid does not take the
master grid id as one of the parameters for the add new option.
It would be great if you could help. Thanks for the cooperation.
09:41

Moderators
30/10/2007

Ok.
I recommend you to use a editurl option. Let suppose that the master grid has master id and detail has a detail id, then (in your case) you can use
a beforeShowForm event (3.2 version) to do that
Here is a piece of code:
jQuery("#detail").jqGrid({...}).navGrid("#pgdetail",{...},
{...}, //edit
{...
beforeShowForm: function(formid) {
// we should get the id of the master here
mid = jQuery("#master").getGridParam("selrow");
if (mid != null ) {
// now we can set it in editurl
jQuery("#detail").setGridParam({editurl:"myurlhere.php?masterid="+mid});
}
}
....
Regards
Tony
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.
Wonderful!! This works great with add option.
But Tony thers one problem now. I have put the beforeshowform function
as you told me. But now after adding a row, the editurl changes
permanently to editurl:”myurlhere.php?masterid=”+mid});
I need it to point to edit function url when im inline editing. But now what
happens is once I add a row, & then if I try to inline edit a row,
the url remains the url for adding the row.
00:31

Moderators
30/10/2007

If I understand right you use booth form edit and inline edit for one grid.
In editRow and saveRow methods there is a parameter url. Use this parameter for these methods.
Regards
Tony
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.
00:33

30/05/2009

Hi Tony,
I am trying to get the same result as this post. Here's my code:
$(”#list_detail”).jqGrid({
height: 100,
width:851,
url:'data/subgrid.php?q=1&id=0',
datatype: “xml”,
mtype: “GET”,
colModel:[
{name:'user_id',index:'user_id', label:'User', align:'center', hidden:true, edittype:”text”, editrules:{number:true}, width:180, editable:true, editoptions:{readonly:true, size:30}},
{name:'app',index:'app', label:'Application', width:200, align:'center', editable:true, edittype:”select”,……….
{add:true,edit:true,del:true,search:false}, //options
{height:200,width:600,reloadAfterSubmit:true,url:'licenseedit.php',closeAfterEdit:true}, // edit options
{height:200,width:600,reloadAfterSubmit:false,
beforeShowForm: function(formid) {
// we should get the id of the master here
var uid = jQuery(”#list”).getGridParam('selrow');
if (uid != null ) {
// now we can set it in editurl
jQuery(”#list_detail”).setGridParam({editurl:'licenseedit.php?user_id='+uid});
}
else alert(”Its not working again”)
}}, // add options
{reloadAfterSubmit:false,url:'licenseedit.php'}, // del options
{width:600} // search options
);
});
Firebug is showing this:
Nothing is being sent for the user_id, which should be the “selrow” value, correct?
app |
1 |
expiration |
2010-06-06 |
id |
_empty |
oper |
add |
user_id |
I know you get many requests for help, but any help is greatly appreciated.
Most Users Ever Online: 715
Currently Online:
74 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66