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
Grid as SubGrid - beforeShowForm - Set Value
22/11/2008
09:40
Avatar
Barry
Texas, USA
Member
Members
Forum Posts: 38
Member Since:
04/11/2008
sp_UserOfflineSmall Offline

Great job on jqgrid. The more I learn the more I like! I've got my reads and edits working great. Trying to iron our the add controls.

In the parent grid I have a key column "ID_1". It is a FK of the child grid.

I click on the + button and the child grid and all the fields are correctly displayed.

I am using the navGrid Add button.

I've been reading the forums for hours and haven't found an example. I found comments and instructions for accessing a selected row in the parent grid, but since I clicked on the + button, the parent row is NOT selected.

When the ADD form is created I want to insert the value of ID_1 from the parent row.

I don't know how to access the value from the parent grids row.

I don't know how to set this value in the ADD form.

beforeShowForm : function(form_id){
  alert('beforeShowForm');
  alert(jQuery("#grid1").getGridParam("selrow"));//is null
  alert("Key from parent row ID_1 = : " + "???");
  form_id.SetValue("ID_1",???);
},          

Thanks

22/11/2008
20:24
Avatar
Barry
Texas, USA
Member
Members
Forum Posts: 38
Member Since:
04/11/2008
sp_UserOfflineSmall Offline

Ok, I figured out how to set the $ID_1 value in the form!

beforeShowForm : function(form_id)
{
  jQuery("#ID_1",form_id).attr("value","999");
}

So how do I get the value of ID_1 from the parent row if its not selected?

24/11/2008
01:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I suppose you use grid as subgrid

When you open the subgrid in subGridRowExpanded the

second parameter is the id of the row - then

subGridRowExpanded : function (sub_id, row_id) {

...

$("#mygrid").setSelection(row_id);

...

}

This will select your row.

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/11/2008
08:40
Avatar
Barry
Texas, USA
Member
Members
Forum Posts: 38
Member Since:
04/11/2008
sp_UserOfflineSmall Offline

Tony,

That makes sense!. I was thinking that since the row was not selected in the exampe that there might be a way of getting the row if it was not selected.

For my project, in this case, it is correct to select the row. I suppose that in trees expand and select node are distinct operations often. In a grid it probably the case that select on expand is almost always correct.

Thanks for you help on this!

Barry

25/11/2008
07:46
Avatar
Barry
Texas, USA
Member
Members
Forum Posts: 38
Member Since:
04/11/2008
sp_UserOfflineSmall Offline

Tony,

SubGrid as Grid configuration (Master-Detail):

I set the row to selected on expand. When I click add to open the modal add dialog the FK index is correctly set in the Add Form.

Here is a problem. The user can select another row in the master grid. If the user selects another row then the add form dialog wil contain the FK value from the new (currently) selected row.

What the SubGrid needs to know is the ID of the row that caused it to open. Have you considered this? Is there a built in solution?

Thanks!

Barry

26/11/2008
01:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Sorry but It is difficult to understand.

What is FK index?

Where is your add button? Where the user click to add  - in master

or in detail?

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.

26/11/2008
07:31
Avatar
Barry
Texas, USA
Member
Members
Forum Posts: 38
Member Since:
04/11/2008
sp_UserOfflineSmall Offline

Tony,

Foreign Key Index - The key that linkes a master - a foreign key is a referential constraint between two tables. Its the key that makes a master-detail relationship.

Add button... both the master table and the detail table has an add button on the bottom of the grid. The problem is with the detail table (sub grid). The sub grid needs to know the FK of the master table . The subgrid needs to know which row is the master. I am currently doing that by setting the selected row and then getting the value from the selected row. That works until the user clicks on another row.

Barry

27/11/2008
03:23
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

One  possible solution for your problem IMHO is to close all opened

subgrids and and then to open only one for editing and other operation.

Currently you can not do this. I have make some little changes so

that this can be done and will be available in the next release.

The little piece of code that would resolve your problem can look like this:

var minuses = table.find("img[src$=minus.gif]").each(function() {

$(this).parents("td").eq(0).click();

});

You should call this in subgrid row expanded event, but should wait

until the next release.

Regards

Tony

to use

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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