Welcome Guest Search | Active Topics | Members | Log In | Register

Relationship is not showing for the first time Options · View
azad_e_s
Posted: Friday, December 10, 2010 7:22:36 AM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
Hi,

I have to tables Branch and Employee.

There is a one-to-many relationship between Branch and Employee.

Upon code generation, WebOrb creates two ActiveRecords for Branch and Employee (with names Branch and Employee respectively).

I have a datagrid as follows with DataGridColumn headerText="Branch" dataField="relatedBranch.branchname:

Code:


 
 
 



There is a button to fill in the dataProvider with clikc even as follows:
MyEnployees = ActiveRecords.Employee.findAll({PageSize:25});


The problem is when I click the button first time the Branch column with dataField="relatedBranch.branchname" does not show any value. But when I click it second time it is fetching the values and every thing works as expected. So how do I attain this on first click


Please help
Cyril
Posted: Friday, December 10, 2010 8:40:42 AM
Rank: Administration
Groups: Administration , Member

Joined: 9/10/2009
Posts: 320
Points: 778
Location: US
Hi,

I think the following part of the WebORB documentation may help you:

http://www.themidnightcoders.com/fileadmin/docs/dotnet/v4/guide/find_options.htm

Especially you should pay attention for the LoadRelations parameter.

Regards,
Cyril
azad_e_s
Posted: Friday, December 10, 2010 11:34:25 PM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
Hi,
Cyril thanks for the tip, but unfortunately it is not working for me. (I'm using WebORB for Java but I assume the .NET documentation works for JAVA too.). The documentation says "The LoadRelations option works only in the direction from a primary key to a foreign key. This applies both to the one-to-many and the one-to-one cardinalities. Loading a 'parent' record (the one with the primary key) from a table which contains the foreign key is not currently supported.". In my case the Branch table is the master (parent) one Employee table is the child. So I think we can not load the relation "RelatedBranch" from ActiveRecords.Employee.

More over the findOptions.Sort = ["EmployeeName"]; ActiveRecords.Employee.findAll(findOptions) is not working. I was looking for the sort function though.

One thing would like to tell you is that when I call ActiveRecords.Employee.findAll() it is not showing the relatedBranch.branchname but when I call it second time it is fetching the values and is showing relatedBranch.branchname and every thing works as expected. What internal functions are happening there.

And can you tell me more about this loadChildRelation function.

Hmmm!!!! what if we create a view (SELECT b.branchname, e.employeename, e.employeecode FROM branch b, employee e WHERE e.branchid = b.branchid ORDER BY e.emplyeename) and put its ActiveRecord as the dataProvider for a DataGrid. Will it be automatically updated (RTMP, client sync) ?. WebOrb is useful to me only if it can provide me with RTMP service. I have no problem switching to your commercial service or enterprise edition.

Please help its rather urgent
azad_e_s
Posted: Monday, December 13, 2010 9:28:08 AM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
Hi,

Any help!!!!!!!!
Cyril
Posted: Monday, December 13, 2010 9:44:26 AM
Rank: Administration
Groups: Administration , Member

Joined: 9/10/2009
Posts: 320
Points: 778
Location: US
Hi,

could you please show me your database schema?

Regards,
Cyril
azad_e_s
Posted: Monday, December 13, 2010 9:51:18 AM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
create table branch (
branchid int(10) unsigned not null auto_increment,
branchcode varchar(8) not null,
branchname varchar(32) not null,
isavalcentre int(1) default 0,
isawarehouse int(1) default 0,
contactperson varchar(32),
address varchar(64),
city varchar(32),
state varchar(32),
country varchar(32),
pin varchar(6),
phone varchar(10),
fax varchar(10),
email varchar(24),
url varchar(64),
notes varchar(128),
tag int(3) default 0,
primary key (branchid),
unique key (branchcode),
unique key (branchname)
) engine=innodb;

create table employee (
userid int(10) unsigned auto_increment,
username varchar(16) not null,
password varchar(16) not null,
cancreate int(1) default 1,
canvalidate int(1) default 0,
candespatch int(1) default 1,
canwarehouse int(1) default 0,
canviewallbranches int(1) default 0,
employeename varchar(64) not null,
code varchar(16),
phone varchar(10),
email varchar(24),
notes varchar(128),
tag int(3) default 0,
branchid int(10) unsigned not null,
index (branchid),
primary key (userid),
unique key (username),
unique key (code),
foreign key (branchid) references branch(branchid) on update cascade on delete restrict
) engine=innodb;
Cyril
Posted: Monday, December 13, 2010 10:38:24 AM
Rank: Administration
Groups: Administration , Member

Joined: 9/10/2009
Posts: 320
Points: 778
Location: US
azad_e_s,

one more thing. please share your code where are you trying to get entries with related elements.

Regards,
Cyril
azad_e_s
Posted: Monday, December 13, 2010 11:38:38 AM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
[Bindable] private var MyUsers:ArrayCollection;

protected function GetUsers():void
{
MyUsers = ActiveRecords.User.findAll({PageSize:25});
}



























Cyril
Posted: Monday, December 13, 2010 12:35:59 PM
Rank: Administration
Groups: Administration , Member

Joined: 9/10/2009
Posts: 320
Points: 778
Location: US
Please try the following:

Code:


[Bindable] private var MyUsers:ArrayCollection;

protected function GetUsers():void
{
...
var findOptions:Object = new Object();
findOptions.PageSize = 20;
findOptions.LoadRelations = [ "RELATED_PROPERTY_NAME" ];

MyUsers = ActiveRecords.User.findAll(findOptions);
...
}


Please make sure that the name RELATED_PROPERTY_NAME is changed to your related property name
azad_e_s
Posted: Monday, December 13, 2010 9:04:07 PM
Rank: Newbie Coder
Groups: Member

Joined: 12/5/2010
Posts: 12
Points: 36
I already tried that code and did again but no use. My related property name is "RelatedBranch". It is working on the second the click.What about this loadChildRelation function?
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v4.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.146 seconds.