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_TopicIcon
How to get primary id of master row
21/06/2008
02:05
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

22/06/2008
03:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

24/06/2008
11:11
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

24/06/2008
11:12
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

also if i spearately alert the value of

the getgridparam value it works & gives me the

value of the selected row in master grid

24/06/2008
11:44
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

28/06/2008
01:37
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

I am getting error setURL is not a function after I have upgraded to 3.2rc.

I have setURL option in the onselectrow.

Can you please give me an example of what you are saying, as the current code doesnt seem to work for 3.2rc.

Thanks,

Mayank

28/06/2008
02:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

28/06/2008
02:51
Avatar
reignchile
New Member
Members
Forum Posts: 1
Member Since:
28/06/2008
sp_UserOfflineSmall Offline

setGridParam({url:newvalue})

29/06/2008
03:46
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

29/06/2008
04:14
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

30/06/2008
03:13
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

01/07/2008
05:48
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

01/07/2008
09:41
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

06/07/2008
04:35
Avatar
mbhramar
Member
Members
Forum Posts: 8
Member Since:
18/06/2008
sp_UserOfflineSmall Offline

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.

07/07/2008
00:31
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

03/06/2009
00:33
Avatar
finedesignz
Member
Members
Forum Posts: 12
Member Since:
30/05/2009
sp_UserOfflineSmall Offline

Hi Tony,

I am trying to get the same result as this post.  Here's my code:

// Begin Detail grid

  $(”#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”,……….

.navGrid('#pager_detail',
            {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.

03/06/2009
01:25
Avatar
finedesignz
Member
Members
Forum Posts: 12
Member Since:
30/05/2009
sp_UserOfflineSmall Offline

I found my mistake:

Forgot to change from POST to GET when processing the data.

BUT IT WORKS!

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information